affectation in if statement

samb sam.bancal at gmail.com
Tue Mar 16 04:37:13 EDT 2010


Thanks for all those suggestions.
They are good!

1) Let's suppose now that instead of just affecting "thing =
m.group(1)", I need to do a piece of logic depending on which match I
entered...

2) Concerning the suggestion :
m = re.match(r'define\s+(\S+)\s*{$', line)
if m:
    thing = m.group(1)

m = re.match(r'include\s+(\S+)$', line)
if m:
    thing = m.group(1)

#etc...

It means that I'll do all the checks, even if the first one did match
and I know that the next will not...

Thanks again.



More information about the Python-list mailing list