Traceback without __class__ attribute ?

Bertrand Geston bergeston at yahoo.fr
Wed Mar 27 13:28:42 EST 2002


Hi Pythonistas,

I am wondering about this (hurting my OO comprehension):

>>> try:
...  5/0
... except:
...  type, value, traceback = sys.exc_info()
...
>>> traceback
<traceback object at 0x0250C1E0>
>>> type(traceback)
<exceptions.ZeroDivisionError instance at 0x0294D278>
>>> traceback.__class__
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
AttributeError: __class__
>>> sys.version
'2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)]'
>>>

Why traceback has no __class__ attribute ?
Is it planned to change ?
Does it mean that exceptions.ZeroDivisionError is an "old style class" ?
What is the best mean to check the type/class in Python 2.2 (and next
versions) ? (and more specifically for dictionnary-like and list-like
objects).

TIA to everybody spending time to satisfy my curiosity (and/or correcting me
if I am wrong in my understanding).

B





More information about the Python-list mailing list