问题
Is there a way to view a list of the IPython variables currently in the workspace without having to send the command 'whos'. I often find myself not remembering what variable names I want to use while typing a command.
In IPython, I have to erase the current line I was typing and send a 'whos' statement to see which variables are currently available. Normally, in GUI based tools like MATLAB I would just look to the right at my Workspace Variable window.
回答1:
As others said, you can have as many frontends as you like on the same Ipython kernel, i.e 2 command windows for one kernel for example. If you are using the Qt console, shortcuts can get you close to what you want.
Start a second tab with the same kernel with Ctrl+Shift+T.
Then you just write your code on the first tab, and, when you need the output of whos
, press Ctrl+PageDown to get to the other tab, and you can run whos
without deleting your code in the first tab.
回答2:
This isn't a direct answer, but may be useful to you anyway. At least on the system I'm on,
Ctrl-a will position the cursor at the beginning of the line
Ctrl-k will 'kill' the line (think cut)
type whos
Ctrl-y will 'yank' the line as it was back (think paste)
These are emacs keybindings, BTW, and show in many places like Bash and anywhere that uses the readline library.
回答3:
You can have as many IPython frontends as you like on a single IPy kernel, so yes, if you wanted another front end you could do that, but it seems heavy-handed. Can you not use IPython Notebook?
回答4:
Are you asking if you can access the variables of IPython from another instance of the shell?
Because the way it is now, you have a single command window where you interact with the shell by issuing commands, so unlike MATLAB there is no other window to view additional information, so I don't see how this would be possible unless you have another instance of IPython somehow accessing the information from your current shell.
So the answer would seemingly be no.
(If it is somehow possible to do this, I'll be just as happy as you to find out though)
回答5:
In iPython notebook, call the magic function, "%qtconsole", and a console will appear with the same kernel. Alternatively, in the Terminal, you can type, "ipython qtconsole --existing" to launch the most recent kernel in the qtconsole. If you know the name of the kernel (as shown in the terminal output when launched), then you can explicitly tell it like so, "ipython qtconsole --existing 87f7d2c0"
来源:https://stackoverflow.com/questions/11991368/display-ipython-variables-without-entering-using-whos