Assignment-in-conditional

Simon Forman rogue_pedro at yahoo.com
Fri Sep 1 00:33:38 EDT 2006


xamdam wrote:
> Thanks for the FAQ, and for the 'casm ;)
>
> What do you think about using alternative syntax (something like 'as')
>
> - max
>
> Fredrik Lundh wrote:
> > xamdam wrote:
> >
> > > I am not sure if this came up before, but I would love to have an
> > > 'assignment-in-conditional' form in python, e.g
> >
> > it's a FAQ, so it has probably come up before:
> >
> > http://pyfaq.infogami.com/why-can-t-i-use-an-assignment-in-an-expression
> >
> > </F>

There are two recipies in the cookbook for doing this:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/202234
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66061

HTH,
~Simon




More information about the Python-list mailing list