Display IPython variables without entering using w

2019-04-06 01:13发布

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.

5条回答
The star\"
2楼-- · 2019-04-06 01:31

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)

查看更多
劳资没心,怎么记你
3楼-- · 2019-04-06 01:34

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"

查看更多
走好不送
4楼-- · 2019-04-06 01:37

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.

查看更多
男人必须洒脱
5楼-- · 2019-04-06 01:41

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.

查看更多
地球回转人心会变
6楼-- · 2019-04-06 01:41

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?

查看更多
登录 后发表回答