Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78637

Re: Is there a way to display source code for Python function?

References <2d5b0e56-992a-481c-9a8b-eb546cd9ac2e@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2014-10-02 23:46 -0600
Subject Re: Is there a way to display source code for Python function?
Newsgroups comp.lang.python
Message-ID <mailman.14570.1412315234.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Oct 2, 2014 at 11:34 PM, Viet Nguyen
<vhnguyenn@yahoo.com.dmarc.invalid> wrote:
> Hi,
>
> When I am debug mode, is there some command which will help display the source code for a Python function of interest?  Much like you'd use "info proc" to display contents of Tcl proc.
>
> Thanks,
> Viet

You can use inspect.getsource() to get the source code for a function,
class, or module. The source must be available at whatever location
the module was imported from, and of course it won't work for anything
implemented in C.

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Is there a way to display source code for Python function? Viet Nguyen <vhnguyenn@yahoo.com> - 2014-10-02 22:34 -0700
  Re: Is there a way to display source code for Python function? Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-02 23:46 -0600
    Re: Is there a way to display source code for Python function? Viet Nguyen <vhnguyenn@yahoo.com> - 2014-10-02 23:13 -0700
  Re: Is there a way to display source code for Python function? Viet Nguyen <vhnguyenn@yahoo.com> - 2014-10-02 23:09 -0700
    Re: Is there a way to display source code for Python function? Peter Otten <__peter__@web.de> - 2014-10-03 09:47 +0200
      Re: Is there a way to display source code for Python function? Viet Nguyen <vhnguyenn@yahoo.com> - 2014-10-03 01:16 -0700
        Re: Is there a way to display source code for Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-10-03 13:04 +0100

csiph-web