Hi,
import re foo_pattern = re.compile('foo')
'>>> m = foo_pattern.search(subject) '>>> if m: '>>> pass '>>> else: '>>> pass
Heh. Did you see Ray Gibbons's 'Testing Conditions' post before you sent this?
I knew if/elif was a much better argument in favour of embedded assignment than while loops are.
Anyway, here's the above using my idle thought from that the thread.:
if m using foo_pattern.search(subject) as m: pass else: pass
And the 'alternative patterns' case:
if m using foo_pattern.search(subject) as m: pass elif m using bar_pattern.search(subject) as m: pass else: pass
(Y'know, I'm pretty sure the impetus was regexp matching the *last* time embedded assignment came up. . .)
Cheers, Nick.
-- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list