"Sander Sweers" <sander.swe...@gmail.com> wrote

What you can do is define all the variables upfront. This way you can
get rid of the else. Below is an example how you can do this with only
looping once over the fle.

And you can put the variables as keys of a dictionary and avoid all the if tests:

data = {'CBUILD':None, 'ACCEPT_KEYWORDS: None,
            ....
           }

for line in fname:
     for keyphrase in data:
          if keyphrase in line:
              output = line.split('"')[1]
              data[keyphrase] = textwrap.fill(output, 80)


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to