Stephen Thorne wrote:
> but it occured to me today, that it is possible to do it in python
> without the extra line.
> '
> '>>> def xsearch(pattern, subject):
> '>>> yield pattern.search(subject)
>
> '>>> for m in xsearch(foo_pattern, subject):
> '>>> pass
> '>>> else:
> '>>> pass
>
>
Hi,
> import re
> foo_pattern = re.compile('foo')
>
> '>>> m = foo_pattern.search(subject)
> '>>> if m:
> '>>>pass
> '>>> else:
> '>>>pass
I agree that is horrible. This is one of my favorite problems with
python syntax.
> but it occured to me today, that it is possible to do it in pyth
Nick Coghlan wrote:
> I knew if/elif was a much better argument in favour of embedded
> assignment than while loops are.
>
I know I'm going to regret posting this, but here is an alternative, very
hackish way to do all those things people keep asking for, like setting
variables in outer scopes
Stephen Thorne wrote:
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 as
> "Stephen" == Stephen Thorne <[EMAIL PROTECTED]> writes:
Stephen> We've all seen it before. Its a horrible idiom that you
Stephen> would achieve in another language by doing:
Stephen> if (m = foo_pattern.search(subject))
Stephen> { }
Stephen> else
Stephen> { }
S
Stephen Thorne wrote:
> We've all seen it before. Its a horrible idiom that you would achieve
> in another language by doing:
>
> if (m = foo_pattern.search(subject))
> { }
> else
> { }
>
> but it occured to me today, that it is possible to do it in python
> without the extra line.
>
> '>>> for m i
Hi,
import re
foo_pattern = re.compile('foo')
'>>> m = foo_pattern.search(subject)
'>>> if m:
'>>>pass
'>>> else:
'>>>pass
We've all seen it before. Its a horrible idiom that you would achieve
in another language by doing:
if (m = foo_pattern.search(subject))
{ }
else
{ }
but it occu