> Is the if-else (esp. 'else') in a list comprehension specific for Python 3.x? 
> Or 
> did I miss something?


Its not part of list comprehensions per se, you can use it in any *expression*.
It was introduced in Python 2.5 as a response to C's ternary operator:

C:
 x = foo?bar:baz

Python
x = bar if foo else baz

So in the list comprehension case we are simply using that standard 
expression syntax as the value part of the LC.

HTH,

Alan G.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to