Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76630
| Date | 2014-08-20 11:05 +0800 |
|---|---|
| From | luofeiyu <elearn2014@gmail.com> |
| Subject | why i can't get the sourcecode with inspect module? |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13186.1408503952.18130.python-list@python.org> (permalink) |
>>> 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
>>>
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
why i can't get the sourcecode with inspect module? luofeiyu <elearn2014@gmail.com> - 2014-08-20 11:05 +0800 Re: why i can't get the sourcecode with inspect module? Steven D'Aprano <steve@pearwood.info> - 2014-08-20 05:00 +0000
csiph-web