[Python-bugs-list] [ python-Bugs-615772 ] Tkinter.Misc has no __contains__ method

noreply@sourceforge.net noreply@sourceforge.net
Fri, 27 Sep 2002 21:34:15 -0700


Bugs item #615772, was opened at 2002-09-28 00:27
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=615772&group_id=5470

Category: Tkinter
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Samuel Bronson (sbronson)
Assigned to: Nobody/Anonymous (nobody)
>Summary: Tkinter.Misc has no __contains__ method

Initial Comment:
This can lead to a lot of confusion.

If I do `"spam" in widget', I get a TypeError.

Case in point: (the code in question is probably
incorrect, so I am not including it)

 /usr/tmp/python-14024DA 
   45             self.pack()
   46 
   47 if __name__ == '__main__':
   48     widget = TkLife(None, height=20, width=20)
   49     widget.loop()
widget undefined
TkLife = <class __main__.TkLife>
None undefined
height undefined
width undefined

 /usr/tmp/python-14024DA in
__init__(self=<__main__.TkLife instance>, master=None,
**kw={'height': 20, 'width': 20})
   27         self['state'] = Tkinter.DISABLED
   28 
   29         if 'cells' not in self:
   30             assert 'width' in self and 'height'
in self
   31             self['cells'] =
randomcells(self['width'], self['height'])
self = <__main__.TkLife instance>

 /usr/local/lib/python2.2/lib-tk/Tkinter.py in
cget(self=<__main__.TkLife instance>, key=0)
 1088     def cget(self, key):
 1089         """Return the resource value for a KEY
given as string."""
 1090         return self.tk.call(self._w, 'cget', '-'
+ key)
 1091     __getitem__ = cget
 1092     def __setitem__(self, key, value):
self = <__main__.TkLife instance>
self.tk = <tkapp object>
self.tk.call = <built-in method call of tkapp object>
self._w = '.135644212'
key = 0
TypeError: cannot concatenate 'str' and 'int' objects
      __doc__ =
'Inappropriate argument type.'
      __getitem__ =
<bound method TypeError.__getitem__ of
<exceptions.TypeError instance at 0x83202cc>>
      __init__ =
<bound method TypeError.__init__ of
<exceptions.TypeError instance at 0x83202cc>>
      __module__ =
'exceptions'
      __str__ =
<bound method TypeError.__str__ of
<exceptions.TypeError instance at 0x83202cc>>
      args =
("cannot concatenate 'str' and 'int' objects",)

The above is a description of an error in a Python
program.  Here is
the original traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/tmp/python-14024DA", line 48, in ?
    widget = TkLife(None, height=20, width=20)
  File "/usr/tmp/python-14024DA", line 29, in __init__
    if 'cells' not in self:
  File "/usr/local/lib/python2.2/lib-tk/Tkinter.py",
line 1090, in cget
    return self.tk.call(self._w, 'cget', '-' + key)
TypeError: cannot concatenate 'str' and 'int' objects


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=615772&group_id=5470