ipython

IPython OS X: Up arrow gives "^[[A"

Hi, Whenever I hit the up arrow in IPython, instead of getting history, I get this set of characters "^[[A" (not including the quotes). Hitting the down arrow gives "^[[B", and tab completion doesn't work (just enters a tab). How can I fix this? It happens in both Terminal and iTerm. Running OS X 10.5, Framework Python 2.5.4. Error...

Is it possible to pass a variable out of a pdb session into the original interactive session?

I am using pdb to examine a script having called run -d in an ipython session. It would be useful to be able to plot some of the variables but I need them in the main ipython environment in order to do that. So what I am looking for is some way to make a variable available back in the main interactive session after I quit pdb. If you ...

Is it possible to go into ipython from code?

For my debugging needs,pdb is pretty good. However, it would be MUCH cooler ( and helpful ) if I could go into ipython. Is this thing possible? ...

Why can't IPython return records with multiple fields when submitting a query to sqlite?

I am trying to write a simple query to an sqlite database in a python script. To test if my parameters were correct, I tried running the query from the ipython command line. It looked something like this: import sqlite3 db = 'G:\path\to\db\file.sqlite' conn = sqlite3.connect(db) results = conn.execute('SELECT * FROM studies').fetchall()...

How do you add a model method to an existing class within an interactive session (in iPython)?

I have a basic model: class Person(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) state = USStateField() I start up an iPython session with: $ python manage.py shell >>> from app.models import Person How do I add this model method within the iPython session? >>> ...

What is required to use ipython in ironpython?

I'd love to use IronPython to explore the .net runtime and libraries, but coming from CPython I miss IPython's completion and shortcuts. Last time I checked IPython couldn't be used due to a lack of sys.getframe, but the latest beta versions included support for it. Is there anything lacking? Can one start to use IPython with IronPyt...

How do I control number formatting in the python interpreter?

I often use the python interpreter for doing quick numerical calculations and would like all numerical results to be automatically printed using, e.g., exponential notation. Is there a way to set this for the entire session? For example, I want: >>> 1.e12 1.0e+12 not: >>> 1.e12 1000000000000.0 ...

Detecting when a python script is being run interactively

Is there a way for a python script to automatically detect whether it is being run interactively or not? Alternatively, can one detect whether ipython is being used versus the regular c python executable? Background: My python scripts generally have a call to exit() in them. From time to time, I run the scripts interactively for debug...

cannot override sys.excepthook

I try to customize behavior of sys.excepthook as described by the recipe. in ipython: :import pdb, sys, traceback :def info(type, value, tb): : traceback.print_exception(type, value, tb) : pdb.pm() :sys.excepthook = info :-- >>> x[10] = 5 ------------------------------------------------- Traceback (most recent call last): File...

scripting ipython through django's shell_plus

I'm writing a shell script which runs a command through ipython with the -c option like this: ipython -c "from blah import myfunct; myfunct()" but I want to invoke ipython through django's shell_plus command so I can take advantage of all the stuff shell_plus automatically loads for me: $ ./manage.py shell_plus I can't just add "-c...

How can I capture the error output from the ipython shell?

I'm writing an ipython macro that processes the output of a program. The thing is, the program can sometimes write to stderr , so if I do something like this : out = !my_program the out variable will not contain the output. I think it will contain the exit code ( correct me if I'm wrong ). How can I capture both stdout and stderr st...

Ipython common problems

I love iPython's so many features, magic functions. I recently upgraded to the latest 0.10 version. But I face following common problems: %hist one of the most frequently used magic functions, doesn't exist. dreload doesn't seems to work (works only for modules?). run -d for debugging doesn't work At times, typed characters are not di...

Running doctests through iPython and pseudo-consoles

I've got a fairly basic doctestable file: class Foo(): """ >>> 3+2 5 """ if __name__ in ("__main__", "__console__"): import doctest doctest.testmod(verbose=True) which works as expected when run directly through python. However, in iPython, I get 1 items had no tests: __main__ 0 tests in 1 items. 0 passe...

How to run django shell from Emacs?

I'd like to be able to run ./manage.py shell in an Emacs buffer, with all the nice stuff that you get from ipython, like magic commands and autocompletion. Ideally I would also like to be able evaluate code from a buffer to the django shell. Is this possible? ...

How to install iPython on Snow Leopard

Does iPython work on Mac OS X 10.6.1 Snow Leopard? I'm python noob, how can I install iPython on my Mac? Links? suggestions? Thanks ...

ipython-error "list indices must be integers" , they ARE integers..

HI there, I am having a problem. I have an array of 31 elements called colors. I also have another array with integer numbers that vary between 0 and 31, this is called c. I want to produce a new array where the values in c are now the corresponding values in colors. I write: newarray=colors[c] but get the error message "...

Cutting text from IPython shell using Ctrl-X is broken

I use IPython very frequently and happily. Somehow, cutting text from the shell using the keyboard shortcut, Ctrl-X, is broken. Actually, I have a few different installations of IPython. In some of the installations, the shortcut works; in the others, it doesn't work. What might be the reason for this? Where should I look into? ...

exit from ipython

I like IPython a lot for working with the python interpreter. However, I continually find myself typing exit to exit, and get prompted "Type exit() to exit." I know I can type Ctrl-D to exit, but is there a way I can type exit without parentheses and get IPython to exit? Update: Thanks to nosklo, this can be easily done by adding the...

IPython tab completes only some modules

I'm using the EPD version of python and IPython. After installing some modules using easy_install I notice that, although they can be imported, they cannot be tab completed. They exist on the path but, while included modules (pylab, readline, math) can be completed, these new modules cannot. Anyone know what I should look into to find t...

IPython in unbuffered mode

Is there a way to run IPython in unbuffered mode? The same way as python -u gives unbuffered IO for the standard python shell ...