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?
#4
(Oct-11-2018, 01:19 PM)Krszt Wrote: 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?
Yes, Itried, but my problem is that it doesnt do anything.
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,222 Mar-16-2022, 08:54 PM
Last Post: cubangt
  how to check for thread kill flag nanok66 1 2,228 May-09-2020, 10:06 PM
Last Post: nanok66
  Check for a special characters in a column and flag it ayomayam 0 2,089 Feb-12-2020, 03:04 PM
Last Post: ayomayam
  Using a flag error blackjesus24 1 1,654 Jan-30-2020, 09:42 AM
Last Post: buran
  Identifying string success flag graham23s 4 3,193 Aug-14-2019, 09:27 PM
Last Post: graham23s
  Practicing using a "flag": please point in right direction magsloo 5 3,171 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