On Tue, Feb 26, 2013 at 7:49 PM, eryksun <[email protected]> wrote:
>
> You can use inspect.getsource(obj) if obj is a module, class, method,
> function, traceback, frame, or code that has a source file (e.g.
> __file__, co_filename) and is defined normally (e.g. class, def):
>
>     >>> import inspect
>     >>> def printsrc(obj): print inspect.getsource(obj)

You ca also use a pager (uses "less" if available; "more" on Windows):

    >>> import inspect, pydoc
    >>> def showsrc(obj): pydoc.getpager()(inspect.getsource(obj))
    ...
    >>> showsrc(inspect)
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to