> 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
- Re: [Tutor] "if clause" in list comprehen... Alan Gauld
- Re: [Tutor] "if clause" in list compr... Sander Sweers
- Re: [Tutor] "if clause" in list c... Douglas Philips
- Re: [Tutor] "if clause" in list compr... Emile van Sebille
- Re: [Tutor] "if clause" in list c... vince spicer
- Re: [Tutor] "if clause" in li... vince spicer
- Re: [Tutor] "if clause" ... Alan Gauld
- Re: [Tutor] "if clause" ... Alan Gauld
- Re: [Tutor] "if clause&qu... Albert-Jan Roskam
- Re: [Tutor] "if clause&qu... Christian Witts
- Re: [Tutor] "if clause&qu... ALAN GAULD
- Re: [Tutor] "if clause&qu... Kent Johnson
- Re: [Tutor] "if clause" in list c... Alan Gauld
- Re: [Tutor] "if clause" in list compr... Emmanuel Ruellan
- Re: [Tutor] "if clause" in list c... ALAN GAULD
- Re: [Tutor] "if clause" in list compr... Eduardo Vieira
- Re: [Tutor] "if clause" in list comprehensions... Wayne