On Wed, Oct 21, 2009 at 3:30 AM, Albert-Jan Roskam <fo...@yahoo.com> wrote:
> Is the if-else (esp. 'else') in a list comprehension specific for Python 3.x? 
> Or did I miss something?

List comps have always allowed a condition since they were introduced:
  [ <expression> for <variable> in <sequence> if <condition> ]

This is the form of the original question.

Conditional expressions of the form
  <value> if <condition> else <alternate value>
are relatively new. The answers to the original question use this as
part of the <expression> term of the list comp. So they are not using
any new list comp syntax, they are using new expression syntax.

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

Reply via email to