>>> 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 "", line 1, in
File "D:\Python34\lib\inspect.py", l
luofeiyu writes:
> >>> import inspect
> >>> def changer(x,y):
> ... return(x+y)
> ...
At this point, you have defined a function. It is accessible via the
‘changer’ name, and the code is available.
But the source code is not available; Python reads standard input but
doesn't preserve it.
>
On Wed, 20 Aug 2014 11:05:26 +0800, luofeiyu wrote:
import inspect
> >>> def changer(x,y):
> ... return(x+y)
The interactive interpreter doesn't store the source code you type. It
compiles it to byte-code, executes the byte-code, and throws the source
code away.
--
Steven
--
http