Tkinter question

Peter Otten __peter__ at web.de
Wed Jun 15 06:06:13 EDT 2005


Nicholas.Vaidyanathan at aps.com wrote:

[I didn't see the original post, so just in case noone mentioned it]

> if(self.buttonx.title.isdigit):

Nicholas, the method is not called unless you add parentheses, e. g:

>>> "1".isdigit # a bound method *always* True in a boolean context
<built-in method isdigit of str object at 0x402711c0>
>>> "1".isdigit() # True only if all chars in the string are digits
True

Another observation. buttonx need not be an attribute.

for y in range(4):
   buttonx = ...

will just work as well, provided you don't want to keep a reference of the
last button created in the loop.

Peter




More information about the Python-list mailing list