ipython

How do I make IPython organize tab completion possibilities by class?

时光怂恿深爱的人放手 提交于 2020-01-03 19:32:51
问题 When an object has hundreds of methods, tab completion is hard to use. More often than not the interesting methods are the ones defined or overridden by the inspected object's class and not its base classes. How can I get IPython to group its tab completion possibilities so the methods and properties defined in the inspected object's class come first, followed by those in base classes? It looks like the undocumented inspect.classify_class_attrs(cls) function along with inspect.getmro(cls)

How do I make IPython organize tab completion possibilities by class?

笑着哭i 提交于 2020-01-03 19:31:39
问题 When an object has hundreds of methods, tab completion is hard to use. More often than not the interesting methods are the ones defined or overridden by the inspected object's class and not its base classes. How can I get IPython to group its tab completion possibilities so the methods and properties defined in the inspected object's class come first, followed by those in base classes? It looks like the undocumented inspect.classify_class_attrs(cls) function along with inspect.getmro(cls)

Starting IPython

限于喜欢 提交于 2020-01-03 17:24:50
问题 I want to run IPython (version 0.12) on my Windows XP computer on which I already have Python 2.7 installed. I installed via the Windows binary installer, but after installation IPython did not show up in the menu and could not be started with the command window, though a IPython folder was created in the C: path. I also tried the other download option (tar.gz and zip), but again failed. Can someone help? 回答1: distribute/setuptools is needed to create the start menu entries. Download and run

Matplotlib Freezes When input() used in Spyder

对着背影说爱祢 提交于 2020-01-03 16:46:10
问题 Windows 7. If I open a plain ipython terminal at the command line I can type: import matplotlib.pyplot as plt plt.plot([1, 2, 3, 4, 5]) plt.show(block=False) input("Hello ") But if I do the same thing in Spyder, as soon as I ask for user input, the Matplotlib window freezes, so I can't interact with it. I need to interact with the plot while the prompt is showing. In both Spyder and the plain console, matplotlib.get_backend() return 'Qt4Agg' Edit: To clarify, I have matplotlib set up where it

How to pass variables from javascript to python in Jupyter?

百般思念 提交于 2020-01-03 15:51:09
问题 As I understand it, I should be able to print the variable foo in the snippet below. from IPython.display import HTML HTML(''' <script type="text/javascript"> IPython.notebook.kernel.execute("foo=97") </script> ''') print(foo) Instead, I see this error message: NameErrorTraceback (most recent call last) <ipython-input-2-91b73ee49ec6> in <module>() 5 </script> 6 ''') ----> 7 print(foo) NameError: name 'foo' is not defined I'm trying to use this answer but struggling to make it work. FWIW, this

Run IPython Notebook in Iframe from another Domain

强颜欢笑 提交于 2020-01-03 15:16:09
问题 I want to run an IPython notebook that is on my server inside an iframe on another server. I get this error: Refused to display 'my_url/Test.ipynb' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN' Here it says I should set some x-frame-header option for this: http://ipython.org/ipython-doc/dev/whatsnew/development.html#iframe-embedding Where can I set this? How to change this X-Frame-Option so that it can be embedded from another site? :) 回答1: Update according to the comment by

python django shell (ipython) unexpected behavior or bug?

流过昼夜 提交于 2020-01-03 12:22:08
问题 Django shell behaves (at least for me) unexpected when working with locale settings. Form validation of a comma separated decimal field works when calling from external script and fails on calling from django shell (ipython). Starting a new Project I got the following files: local_forms/ ├── local_forms │ ├── __init__.py │ ├── models.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── manage.py ├── my_form.py ├── test_form.py local_forms/models.py: from django.db import models class MyModel

Paging stdout output in IPython

南笙酒味 提交于 2020-01-03 10:07:12
问题 Is it possible in an (interactive) IPython session to pass the stdout output through a pager, like less ? If so, how? For example, in In [1]: from some_module import function_that_prints_a_lot In [2]: function_that_prints_a_lot() ... everything scrolls away ... I would like to page through the stdout output of function_that_prints_a_lot . Another example: In [1]: %run script_that_prints_a_lot.py I've looked through IPython magic commands but didn't find any solution. 回答1: As discussed in chat

Detect if python script is run from an ipython shell, or run from the command line

﹥>﹥吖頭↗ 提交于 2020-01-03 09:06:37
问题 Is there any way to detect if a python script is being run from an python or ipython shell, or being run from the command line using for example python scrip.py ? I want to use this to set up my matplotlib environment and save or display a figure depending on how the script is run. When I'm running the plotting script from the command line I want the script to use a non-standard matplotlib backend and save the figure to a file with plt.savefig() , but if I'm running it from inside an ipython

Is it possible to run commands in IPython with debugging?

时光毁灭记忆、已成空白 提交于 2020-01-03 07:25:09
问题 Here are my actions in IPython: > import my_module > import ipdb Now, my module lacks any executable code, it only declares classes. So I want to make a statement: > g = my_module.Graph() > f = open('test.osm') > g.from_osm(f) I want to put a breakpoint inside Graph.from_osm, without editing the file. I don't want to put the latter lines into the file and to do python -m ipdb ... . I just want to run commands and debug. Is this possible? added: I see, it's possible to %run -d script_name or >