Hello,
I am trying to use pylab interactively from the Ipython shell with the -pylab option on windows.
Normally, the Ipython shell has the nice “who” command that enables one to see only the variables defined by him,
rather than the many non-relevant output produced by the python dir() function.
for example:
In [1]: a=2
In [2]: who
a
Now, with the pylab option, this command does not work. It gives the output:
In [4]: who
Out[4]: <function who at 0x0141FAF0>
The same thing happens when I do not use the Ipython -pylab option but just import pylab from Ipython:
In [1]: a=2
In [2]: who
a
In [3]: from pylab import *
In [4]: who
Out[4]: <function who at 0x0141FAF0>
Why is this happening?Is there a way to use the who command with pylab ?
Thanks
Eli Brosh
In [1]: a=2
In [2]: who
a
In [3]: from pylab import *
In [4]: who
Out[4]: <function who at 0x0141FAF0>
Why is this happening?
Because pylab provides its own who _function_, which overrides the
ipython command ('magic function', in ipythonese).
Is there a way to use the who command with pylab ?
Try
%who
instead. The '%' disambiguates and tells ipython that you are
explicitly after the magic function, not any other python fuction
currently available.
Regards,
f
···
On Fri, Jul 11, 2008 at 12:02 PM, Eli Brosh <ebrosh1@...287...> wrote:
Thanks Fernando,
I now tried %who.
The result was a huge output, apparently containing all the pylab functions.
This is exactly the thing I was trying to avoid.
I wanted to use the who command to see only the variables I defined as part of the pylab session.
Is there a way to do just this ?
thank
Eli Brosh
···
On Fri, Jul 11, 2008 at 3:10 PM, Fernando Perez <fperez.net@gmail.com> wrote:
On Fri, Jul 11, 2008 at 12:02 PM, Eli Brosh <ebrosh1@…287…> wrote:
In [1]: a=2
In [2]: who
a
In [3]: from pylab import *
In [4]: who
Out[4]: <function who at 0x0141FAF0>
Why is this happening?
Because pylab provides its own who function, which overrides the
ipython command (‘magic function’, in ipythonese).
Is there a way to use the who command with pylab ?
Try
%who
instead. The ‘%’ disambiguates and tells ipython that you are
explicitly after the magic function, not any other python fuction
currently available.
Regards,
f
Yes, update ipython The problem you mention is fixed in the
current version already:
maqroll[books]> ipython -pylab
Python 2.5.2 (r252:60911, May 7 2008, 15:19:09)
Type "copyright", "credits" or "license" for more information.
IPython 0.9.0.bzr.r1016 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
Welcome to pylab, a matplotlib-based Python environment.
For more information, type 'help(pylab)'.
In [1]: %who
Interactive namespace is empty.
In [2]: a = 1
In [3]: %who
a
In [4]:
regards
f
···
On Fri, Jul 11, 2008 at 12:19 PM, Eli Brosh <ebrosh1@...287...> wrote:
Thanks Fernando,
I now tried %who.
The result was a huge output, apparently containing all the pylab functions.
This is exactly the thing I was trying to avoid.
I wanted to use the who command to see only the variables I defined as part
of the pylab session.
Is there a way to do just this ?
Eli Brosh wrote:
Thanks Fernando,
I now tried %who.
The result was a huge output, apparently containing all the pylab functions.
This is exactly the thing I was trying to avoid.
I wanted to use the who command to see only the variables I defined as part of the pylab session.
Is there a way to do just this ?
Maybe the pylab command does what you want; you have to include the trailing parentheses:
efiring@...2091...:~$ ipython -pylab
[...]
In [2]:x = arange(20)
In [3]:who()
Name Shape Bytes Type
···
===========================================================
x 20 80 int32
Upper bound on total bytes = 80
Eric
Thanks to Eric and Fernando
I will try to update ipython (for some reason I have troubles with that in windows).
The ipython -pylab[…]
with who() command works but it seems to work only for arrays.
i.e. with x = arange(20) it worked but not with x=1.
Hence updating ipython remains the only way.
Thanks
Eli
···
On Fri, Jul 11, 2008 at 3:57 PM, Eric Firing <efiring@…202…> wrote:
Eli Brosh wrote:
Thanks Fernando,
I now tried %who.
The result was a huge output, apparently containing all the pylab functions.
This is exactly the thing I was trying to avoid.
I wanted to use the who command to see only the variables I defined as part of the pylab session.
Is there a way to do just this ?
Maybe the pylab command does what you want; you have to include the trailing parentheses:
efiring@…2091…:~$ ipython -pylab
[…]
In [2]:x = arange(20)
In [3]:who()
Name Shape Bytes Type
===========================================================
x 20 80 int32
Upper bound on total bytes = 80
Eric