very good reasons?

Alex Martelli aleaxit at yahoo.com
Thu Oct 5 09:33:09 EDT 2000


"Greg Ewing" <see at my.signature> wrote in message
news:39D7F021.C2D5091D at my.signature...
> Pete Shinners wrote:
> >
> > b = a.sort() or a.reverse() or a
>
> Yeeek! That must be the most misleading piece of
> Python I've ever seen! It sounds like you're
> either sorting or reversing or doing nothing,
> when you're actually doing all three.
>
> If you really want an obfuscated way of writing
> it, how about
>
> b = (a.sort(), a.reverse(), a)[-1]

Hmmm -- it does work with the current implementation
(because sort is called first, then reverse) but I
wonder whether it's guaranteed to keep working for
all time.  Is left-to-right order of evaluation for
tuple-constructor components guaranteed somewhere in
the language specs?  A pointer would be welcome...


Alex






More information about the Python-list mailing list