Insane crazy question - printing commands

Donn donn.ingle at gmail.com
Tue Nov 6 12:42:08 EST 2007


> import inspect
>
> class Box:
>     def draw(self):
>         print "hi"
>         return 3
>
> x = Box()
> print inspect.getsource(x.draw)

Tried that, but get this error. I did a dir(inspect) in the command env. and 
getsource it definitely there...

Traceback (most recent call last):
  File "inspect.py", line 1, in ?
    import inspect
  
File "/home/donn/Projects/pythoning/fontyPython/extending/cairotests/containers/inspect.py", 
line 9, in ?
    print inspect.getsource(x.draw)
AttributeError: 'module' object has no attribute 'getsource'


/d



More information about the Python-list mailing list