why i can't get the sourcecode with inspect module?

luofeiyu elearn2014 at gmail.com
Tue Aug 19 23:05:26 EDT 2014


 >>> import inspect
 >>> def changer(x,y):
...     return(x+y)
...
 >>> dir()
['__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__
  'changer', 'inspect']
 >>> inspect.getsource(changer)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "D:\Python34\lib\inspect.py", line 830, in getsource
     lines, lnum = getsourcelines(object)
   File "D:\Python34\lib\inspect.py", line 819, in getsourcelines
     lines, lnum = findsource(object)
   File "D:\Python34\lib\inspect.py", line 667, in findsource
     raise OSError('could not get source code')
OSError: could not get source code
 >>>



More information about the Python-list mailing list