ipython

Ipython bash/shell cell magics: can I have persistent variables between cells?

為{幸葍}努か 提交于 2019-12-20 03:13:09
问题 This is my first post on SO, so please tell me if I am doing something wrong. I am interested in using different programming languages in ipython, similar to babel/literal programming in emacs org mode. What I like about emacs org mode is that one can have multiple "cells" connecting to the same R/bash session. This allows me to re-use variables/functions created in an earlier part of the document, even if I do something else in between. I have found that this is possible in ipython with the

problems exiting from Python using iPython/Spyder

浪尽此生 提交于 2019-12-20 02:51:07
问题 This question has been asked before, but I have tried the solutions in related questions such as this to no avail. I am having problems with Python's exit command, and I have ruled out a problem with my code as run by vanilla Python 3. The problem comes when I run it with iPython or in Spyder's iPython console. When I use just a simple exit command, I get the error: NameError: name 'exit' is not defined I have already imported sys as suggested by the other link. The only thing that kind of

how to show all methods that i can choose in ipython notebook?

青春壹個敷衍的年華 提交于 2019-12-19 23:22:42
问题 I'm new to ipython notebook. When typing a code line, it should show all methods or attributes that I can choose. However, it didn't, and I'm not sure why. It should look like this: Does anyone know how I can get this to work? 回答1: Type the library name Type period symbol . Press tab At this point you will see drop down menu (showing all the methods) This works for both python 2 and python 3 回答2: That should be a new feature of IPython 6.0. But as mentioned in the official release post, is

how to show all methods that i can choose in ipython notebook?

青春壹個敷衍的年華 提交于 2019-12-19 23:19:47
问题 I'm new to ipython notebook. When typing a code line, it should show all methods or attributes that I can choose. However, it didn't, and I'm not sure why. It should look like this: Does anyone know how I can get this to work? 回答1: Type the library name Type period symbol . Press tab At this point you will see drop down menu (showing all the methods) This works for both python 2 and python 3 回答2: That should be a new feature of IPython 6.0. But as mentioned in the official release post, is

Override ipython exit function - or add hooks in to it

瘦欲@ 提交于 2019-12-19 21:26:51
问题 In my project manage, I am embedding iPython with: from IPython import start_ipython from traitlets.config import Config c = Config() c.TerminalInteractiveShell.banner2 = "Welcome to my shell" c.InteractiveShellApp.extensions = ['autoreload'] c.InteractiveShellApp.exec_lines = ['%autoreload 2'] start_ipython(argv=[], user_ns={}, config=c) It works well and opens my iPython console, but to leave ipython I can just type exit or exit() or press ctrl+D . What I want to do is to add an exit hook

Override ipython exit function - or add hooks in to it

痞子三分冷 提交于 2019-12-19 21:24:01
问题 In my project manage, I am embedding iPython with: from IPython import start_ipython from traitlets.config import Config c = Config() c.TerminalInteractiveShell.banner2 = "Welcome to my shell" c.InteractiveShellApp.extensions = ['autoreload'] c.InteractiveShellApp.exec_lines = ['%autoreload 2'] start_ipython(argv=[], user_ns={}, config=c) It works well and opens my iPython console, but to leave ipython I can just type exit or exit() or press ctrl+D . What I want to do is to add an exit hook

Tell IPython to use an object's `__str__` instead of `__repr__` for output

你说的曾经没有我的故事 提交于 2019-12-19 17:32:13
问题 By default, when IPython displays an object, it seems to use __repr__ . __repr__ is supposed to produce a unique string which could be used to reconstruct an object, given the right environment. This is distinct from __str__ , which supposed to produce human-readable output. Now suppose we've written a particular class and we'd like IPython to produce human readable output by default (i.e. without explicitly calling print or __str__ ). We don't want to fudge it by making our class's __repr__

Can I get a python object from its memory address?

纵饮孤独 提交于 2019-12-19 16:13:51
问题 I'm learning how to use Qt with PyQt, and I have a QTabelView with a StandardItemModel I've populated the model successfully and hooked up the itemChanged signal to a slot. I'd l'd like to mess around with whatever object is returned in IPython, so currently I have the line: def itemChangedSlot(epw, item): new_data = item.data() print new_data print item which prints <PyQt4.QtGui.QStandardItem object at 0x07C5F930> <PyQt4.QtCore.QVariant object at 0x07D331F0> In the IPython session is it

Can I get a python object from its memory address?

烈酒焚心 提交于 2019-12-19 16:13:17
问题 I'm learning how to use Qt with PyQt, and I have a QTabelView with a StandardItemModel I've populated the model successfully and hooked up the itemChanged signal to a slot. I'd l'd like to mess around with whatever object is returned in IPython, so currently I have the line: def itemChangedSlot(epw, item): new_data = item.data() print new_data print item which prints <PyQt4.QtGui.QStandardItem object at 0x07C5F930> <PyQt4.QtCore.QVariant object at 0x07D331F0> In the IPython session is it

Can I get a python object from its memory address?

社会主义新天地 提交于 2019-12-19 16:12:46
问题 I'm learning how to use Qt with PyQt, and I have a QTabelView with a StandardItemModel I've populated the model successfully and hooked up the itemChanged signal to a slot. I'd l'd like to mess around with whatever object is returned in IPython, so currently I have the line: def itemChangedSlot(epw, item): new_data = item.data() print new_data print item which prints <PyQt4.QtGui.QStandardItem object at 0x07C5F930> <PyQt4.QtCore.QVariant object at 0x07D331F0> In the IPython session is it