a list or not a list?

Axel Grune NineOfSix at gmx.de
Wed May 7 08:46:16 EDT 2003


Hi , I played around with the traceback module and I noticed something 
strange. When you execute this code

import traceback

class PseudoFile( object):
   def write( self, data):
     print type( data)
     print len( data)

a = 'a'
try:
   b = a + 1
except:
   pseudo = PseudoFile()
   traceback.print_exc( file=pseudo)

you get this output

<type 'str'>
35
<type 'str'>
39
<type 'str'>
14
<type 'str'>
54

but I expected something like this

<type 'list'>
4

The output of print_exc does not seem to be a list or a tuple, so: what 
is it? Another thing is that the write method seems to be excuted four 
times, once for every string.

TIA,
Axel

--

Michael Moore for president!





More information about the Python-list mailing list