[Tutor] There's a Programmer in Me
Femi Banjo
femibanjo at hotmail.com
Wed Feb 27 12:19:43 CET 2013
coursera, udacity & edx all have decent Python courses for beginners and very good support on forums etc and they're all free
> Date: Wed, 27 Feb 2013 01:10:07 -0800
> From: fomcl at yahoo.com
> To: eryksun at gmail.com
> CC: tutor at python.org
> Subject: Re: [Tutor] There's a Programmer in Me
>
>
>
> > On Tue, Feb 26, 2013 at 4:00 PM, Albert-Jan Roskam <fomcl at yahoo.com>
> > wrote:
> >>
> >> What I like about R: if I do 'print(func)' (or fix(func)), it
> > prints the
> >> source code of the function. It would be cool if Python had something
> >> similar. Instead Python prints the not-so-informative
> >> <function func at 0xa82fae4>
> >
> > 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)
> >
> > >>> import antigravity
> > >>> printsrc(antigravity)
> >
> > import webbrowser
> >
> > webbrowser.open(http://xkcd.com/353/)
>
> Ahh, thank you! I like the %psource magic word, but until I get IPython installed in the office I'll use inspect.getsource.
> import inspect, soul
> print inspect.getsource(soul.getsoul)
> import webbrowser
> webbrowser.open(http://xkcd.com/413/) ;-))
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130227/4ce1c897/attachment.html>
More information about the Tutor
mailing list