This is just a sneaky shorthand, which is fine if that's what you want, but it makes it harder to read.  The reason it works is that 'fill==True' is a boolean expression, which evaluates to True or False, but if you force a True into being an integer, it will be 1, and a False will become 0.  Try writing 'True == 1' on the Python interpreter to see what I mean.  So this code snippet is creating a tuple with two elements, and then selecting the first if 'fill==True' is False, or 0, and selecting the second if 'fill==True' is True, or 1.<br>
<br>As I say, this kind of coding is absolutely fine, but it makes things harder to read and doesn't really save much space.  I wouldn't recommend using this kind of style yourself, at least until you're more familiar with programming in Python.<br>
<br>Tom<br><br><div class="gmail_quote">On 29 September 2010 11:42, Tracubik <span dir="ltr"><<a href="mailto:affdfsdfdsfsd@b.com">affdfsdfdsfsd@b.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi all,<br>
I'm studying PyGTK tutorial and i've found this strange form:<br>
<br>
button = gtk.Button(("False,", "True,")[fill==True])<br>
<br>
the label of button is True if fill==True, is False otherwise.<br>
<br>
i have googled for this form but i haven't found nothing, so can any of<br>
you pass me any reference/link to this particular if/then/else form?<br>
<br>
thanks<br>
Nico<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>