affectation in if statement

samb sam.bancal at gmail.com
Tue Mar 16 10:53:51 CET 2010


On Mar 16, 9:53 am, Chris Rebert <c... at rebertia.com> wrote:
> On Tue, Mar 16, 2010 at 1:37 AM, samb <sam.ban... at gmail.com> wrote:
> > Thanks for all those suggestions.
> > They are good!
> <snip>
> > 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...
>
> Note how I split it out into a separate function and used `return
> m.group(1)` to avoid that exact situation.

Yes, you're right.
It's an interresting approach. I'll give it a try.

Cheers



More information about the Python-list mailing list