Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; 'class,': 0.07; 'debug': 0.07; 'subject:code': 0.07; 'function,': 0.09; 'imported': 0.09; 'python': 0.11; 'mode,': 0.16; 'tcl': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'module': 0.19; 'thu,': 0.19; 'command': 0.22; 'source': 0.25; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'implemented': 0.33; 'display': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'module.': 0.36; 'subject:?': 0.36; 'hi,': 0.36; 'whatever': 0.38; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'course': 0.61; 'subject:there': 0.68; 'nguyen': 0.84; 'subject:source': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=TwOIbDOLWMR+BIVnrgcW9GpOsS8p00D1O7qcUQ6i468=; b=hDlEaFsXt9HF+vu9BwGRkVqcr4Cxi4BgWfSizG3dL8TXtU7WPRlItqxs7svIsNSQiM gju51fUtOMA4fB1p5MkbHtC/0hIRaMjZKwSAe7Xz5rW0ydn9AzCKF4uFBJdNhshgJiTc M9LJS0kETYE1HTtDNyS2JRExAlxq0VT3T3fKiaexIbL6R08fFwt7U3Jl5FxyZFZWYYTp BRYrw+bqznU0B7uJOrmowDyde7AdBUZcXjlYrLZRh+vvflGq18d+SD+PsHj7GUeYrbN8 OKmC65g6eiXcAaJKPDtnrgrHh+yIbOdTC/GcxtC7YSxCnUuhNwkJhZCiy2+D/sPDQCWX aO5A== X-Received: by 10.70.88.37 with SMTP id bd5mr429700pdb.89.1412315225551; Thu, 02 Oct 2014 22:47:05 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <2d5b0e56-992a-481c-9a8b-eb546cd9ac2e@googlegroups.com> References: <2d5b0e56-992a-481c-9a8b-eb546cd9ac2e@googlegroups.com> From: Ian Kelly Date: Thu, 2 Oct 2014 23:46:25 -0600 Subject: Re: Is there a way to display source code for Python function? To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1412315234 news.xs4all.nl 2870 [2001:888:2000:d::a6]:57095 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78637 On Thu, Oct 2, 2014 at 11:34 PM, Viet Nguyen 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.