On 25 February 2011 15:49, <[email protected]> wrote:

> >>> append = True
> >>> (lambda x: x and 'a' or 'w')(append)
> 'a'
> >>> append = False
> >>> (lambda x: x and 'a' or 'w')(append)
> 'w'
>

By the way, alternative options would be:

>>> append = True
>>> append and 'a' or 'w'
'a'
>>> append = False
>>> append and 'a' or 'w'
'w'

Of course, the
>>> 'a' if append else 'w'

is nicer, but has only been supported for python 2.5+.

An alternative, third, method, would be

>>> append = True
>>> ['w', 'a'][append]
'a'
>>> append = False
>>> ['w', 'a'][append]
'w'

No reason to change the working code, of course, but just possibilies to
keep in mind.

Best regards,
Merlijn
_______________________________________________
Pywikipedia-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l

Reply via email to