if the else short form

bruno.desthuilliers at gmail.com bruno.desthuilliers at gmail.com
Thu Sep 30 06:42:29 EDT 2010


On 29 sep, 19:20, Seebs <usenet-nos... at seebs.net> wrote:
> On 2010-09-29, Tracubik <affdfsdfds... at b.com> wrote:
> > button = gtk.Button(("False,", "True,")[fill==True])

> Oh, what a nasty idiom.
>

Well, it's not very different from dict-based dispatch , which is the
core of OO polymorphic dispatch in quite a few dynamic OOPLs.

Anyway, it's a common Python idiom and one that's not specially hard
to grasp so I don't see any legibility problem here.



More information about the Python-list mailing list