ipython question
superpollo
utente at esempio.net
Wed May 19 16:14:43 EDT 2010
superpollo ha scritto:
> Robert Kern ha scritto:
>> 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
>
> but still:
>
> In [218]: def f():
> .....: return 42
> .....:
>
> In [219]: %save tmp.py 218
> File `tmp.py` exists. Overwrite (y/[N])? y
> The following commands were written to file `tmp.py`:
> def f():
> return 42
>
>
> In [220]: !cat tmp.py
> def f():
> return 42
>
> In [221]: %psource f
> No source found for f
maybe i got it:
In [230]: import tmp
In [231]: %psource tmp.f
def f():
return 42
More information about the Python-list
mailing list