Python Forum
How to make an activation flag?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make an activation flag?
#1
Hello,
I have a program, which runs well.
It looks like

os.chdir('zips')
a = open("ziplist.txt", "w")
for path, subdirs, files in os.walk(r'./'):
    for filename in files:
        if filename.endswith(".zip"):
            commands....
            for line in open('%s.txt' % (date_ID)).readlines():
                if line.startswith('range_samples:'):
                    commands...
                    os.chdir('../')
Now I want to expand it with an if/else statement as an activation flag, something like: if the first argv is 1, run the whole program written above
and else do nothing.

I am trying it like this:

if activate_flag == 1 :
    os.chdir('zips')
    a = open("ziplist.txt", "w")
    for path, subdirs, files in os.walk(r'./'):
        for filename in files:
            if filename.endswith(".zip"):
                commands....
                for line in open('%s.txt' % (date_ID)).readlines():
                    if line.startswith('range_samples:'):
                       commands...
                       os.chdir('../')
else: 
   print("NO")
But it just write out the else statement: NO
Where is my mistake?
Reply


Messages In This Thread
How to make an activation flag? - by Krszt - Oct-11-2018, 01:19 PM
RE: How to make an activation flag? - by ichabod801 - Oct-11-2018, 01:21 PM
RE: How to make an activation flag? - by buran - Oct-11-2018, 01:40 PM
RE: How to make an activation flag? - by Krszt - Oct-11-2018, 01:49 PM
RE: How to make an activation flag? - by nilamo - Oct-11-2018, 09:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Big Grin Variable flag vs code outside of for loop?(Disregard) cubangt 2 1,260 Mar-16-2022, 08:54 PM
Last Post: cubangt
  how to check for thread kill flag nanok66 1 2,245 May-09-2020, 10:06 PM
Last Post: nanok66
  Check for a special characters in a column and flag it ayomayam 0 2,105 Feb-12-2020, 03:04 PM
Last Post: ayomayam
  Using a flag error blackjesus24 1 1,676 Jan-30-2020, 09:42 AM
Last Post: buran
  Identifying string success flag graham23s 4 3,221 Aug-14-2019, 09:27 PM
Last Post: graham23s
  Practicing using a "flag": please point in right direction magsloo 5 3,220 May-10-2019, 04:58 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020