if the else short form
Antoon.Pardon at rece.vub.ac.be
Fri Oct 1 12:09:46 CEST 2010
On Wed, Sep 29, 2010 at 05:58:16AM -0700, bruno.desthuilliers at gmail.com wrote:
> On 29 sep, 13:38, Hrvoje Niksic <hnik... at xemacs.org> wrote:
> > Tracubik <affdfsdfds... at b.com> writes:
> > > button = gtk.Button(("False,", "True,")[fill==True])
> > BTW adding "==True" to a boolean value is redundant and can even break
> > for logically true values that don't compare equal to True (such as the
> > number 10 or the string "foo").
> Note that if fill is actually an int outside the (0, 1) domain, it
> will break too. The correct test would be:
> ("False,", "True,")[bool(fill)])
That is assuming the original coder would want the argument "True,"
in such cases. You don't know that.
More information about the Python-list