All Samples(287) | Call(263) | Derive(0) | Import(24)
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.
def getsource(object):
"""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(lines, '')
def main():
print
print bar
dis.dis(bar)
print compiler.parse(inspect.getsource(bar))
src/p/y/py2js-HEAD/examples/ui.py py2js(Download)
]
source = ""
for f in funcs:
source += inspect.getsource(f) + "\n"
js = convert_py2js(source)
print """\
src/z/a/zamboni-lib-HEAD/lib/python/IPython/OInspect.py zamboni-lib(Download)
return None
else:
try:
src = inspect.getsource(obj)
except TypeError:
if hasattr(obj,'__class__'):
src = inspect.getsource(obj.__class__)
src/s/a/sage-HEAD/trunk/local/lib/python2.4/site-packages/IPython/OInspect.py sage(Download)
def psource(self,obj,oname=''):
"""Print the source code for an object."""
# Flush the source cache because inspect can return out-of-date source
linecache.checkcache()
try:
src = inspect.getsource(obj)
linecache.checkcache()
try:
if not binary_file:
source = self.format(inspect.getsource(obj))
out.write(header('Source:\n')+source.rstrip())
except:
if ds:
src/s/a/sage-HEAD/local/lib/python2.4/site-packages/IPython/OInspect.py sage(Download)
def psource(self,obj,oname=''):
"""Print the source code for an object."""
# Flush the source cache because inspect can return out-of-date source
linecache.checkcache()
try:
src = inspect.getsource(obj)
linecache.checkcache()
try:
if not binary_file:
source = self.format(inspect.getsource(obj))
out.write(header('Source:\n')+source.rstrip())
except:
if ds:
src/s/y/sympy-old-HEAD/doc/generate_reference.py sympy-old(Download)
def get_method_args(x):
from inspect import getsource
try:
s = getsource(x)
except TypeError:
return ""
s = s[s.find("("):s.find(":")]
src/s/y/sympy-tensor-HEAD/doc/generate_reference.py sympy-tensor(Download)
def get_method_args(x):
from inspect import getsource
try:
s = getsource(x)
except TypeError:
return ""
s = s[s.find("("):s.find(":")]
src/s/y/sympy-HEAD/doc/generate_reference.py sympy(Download)
def get_method_args(x):
from inspect import getsource
try:
s = getsource(x)
except TypeError:
return ""
s = s[s.find("("):s.find(":")]
src/i/p/ipython-0.10/IPython/OInspect.py ipython(Download)
return None
else:
try:
src = inspect.getsource(obj)
except TypeError:
if hasattr(obj,'__class__'):
src = inspect.getsource(obj.__class__)
src/s/i/simpledoc-0.1/simpledoc/simpledoc.py simpledoc(Download)
[<a href="#" onclick="show_source('%s_%s_%s');">show source</a>]
</div>""" % (method.__module__, method.im_class.__name__, method.__name__)
code = inspect.getsource(method)
code = highlight(code, PythonLexer(), HtmlFormatter(classprefix="native_", style=get_style_by_name('native')))
sourcediv = """
[<a href="#" onclick="show_source('%s_%s');">show source</a>]
</div>""" % (func.__module__, func.__name__)
code = inspect.getsource(func)
code = highlight(code, PythonLexer(), HtmlFormatter(classprefix="native_", style=get_style_by_name('native')))
sourcediv = """
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next