if the else short form
Sion Arrowsmith
sion at viridian.paintbox
Thu Sep 30 06:21:49 EDT 2010
Andreas Waldenburger <usenot at geekmail.INVALID> wrote:
><http://docs.python.org/release/3.1/reference/datamodel.html#the-standard-type-hierarchy>
> [ ... ]
> Boolean values behave like the values 0 and 1, respectively, in
> almost all contexts, the exception being that when converted to a
> string, the strings "False" or "True" are returned, respectively.
Hmm. So the original problem of:
button = gtk.Button(("False,", "True,")[fill==True])
could also rewritten as:
button = gtk.Button(str(bool(fill))+",")
--
\S
under construction
More information about the Python-list
mailing list