extended list comprehensions
Greg Ewing
look at replyto.address.invalid
Mon May 27 01:13:30 EDT 2002
Andrew Dalke wrote:
>
> y = "prefix-"
> {y=y+x for x in xs}
>
> But given that, if y doesn't exist before the {} is called, your
> argument is that it should implicitly be set to 0. This then would
> be one of the few places in Python with a default value, outside of
> a function parameter definitions.
Hmmm, maybe something like
(y = y + x for x in xs from y = 0)
Or maybe not. I think this sort of thing is just
too rare to be worth a special syntax, as much
fun as it may be devising one!
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list