2009/4/29 David <[email protected]>:
> Here is the whole program so far, what it does is it logs into a druple web
> site and posts. I would like to make it better, as you can see I do the same
> thing over and over.
>
> http://linuxcrazy.pastebin.com/m7689c088
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.
CBUILD = ''
ACCEPT_KEYWORDS = ''
for line in fname:
if 'ACCEPT_KEYWORDS' in line:
output = line.split('"')[1]
ACCEPT_KEYWORDS = textwrap.fill(output, 80)
if 'CBUILD' in line:
output = line.split('"')[1]
CBUILD = textwrap.fill(output, 80)
etc etc
Greets
Sander
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor