ipython question

Robert Kern robert.kern at gmail.com
Wed May 19 16:01:34 EDT 2010


On 5/19/10 12:11 PM, superpollo wrote:
> In [39]: def f():
> ....: return 42
> ....:
>
> In [40]: %psource f
> No source found for f
>
> In [41]:
>
> i expected to see the source...

You will want to ask IPython questions on the IPython mailing list:

   http://mail.scipy.org/mailman/listinfo/ipython-user

The reason you do not get the source is because there is no file that contains 
functions defined in the interactive interpreter. %psource uses the inspect 
module, and the inspect module explicitly only looks in real files using the 
linecache module. IPython could be modified to inject fake files into the 
linecache, but that's a chunk of work. I am sure they would be happy to 
incorporate a patch if you were to provide it to them.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list