Dark Wind schrieb:
Yes, it's posible to retrieve the source code IFF the function is
implemented in Python and the .py file is available, too.
def getsource(objec t):
"""Return the text of the source code for an object.
The argument may be a module, class, method, function, traceback, frame,
or code object. The source code is returned as a single string. An
IOError is raised if the source code cannot be retrieved."""
lines, lnum = getsourcelines( object)
return string.join(lin es, '')
Hi,
>
Is there any command in Python which gives the code for a function like just
typing the name of a function (say svd) in R returns its code.
>
Is there any command in Python which gives the code for a function like just
typing the name of a function (say svd) in R returns its code.
implemented in Python and the .py file is available, too.
>>print inspect.getsour ce(inspect.gets ource)
"""Return the text of the source code for an object.
The argument may be a module, class, method, function, traceback, frame,
or code object. The source code is returned as a single string. An
IOError is raised if the source code cannot be retrieved."""
lines, lnum = getsourcelines( object)
return string.join(lin es, '')