Python shell on mac os x

Alex Martelli aleax at mac.com
Fri Mar 16 04:08:47 CET 2007


Bert Heymans <bert.heymans at gmail.com> wrote:

> Hi!
> 
> I'm using iTerm on the mac the keymapping isn't right. On Linux and
> Windows it's really nice to be able to hit up to get the previous
> command. Does anyone know a way to get the Pyhton shell to work like
> on other systems, I always get this when I hit the direction keys:
> 
> >>> ^[OA^[OC^[OD
> 
> I've been looking for the correct mappings but can't find a proper
> reference online nor what the Python shell expects. Any help would be
> greatly appreciated! Hints/suggestions on keywords to use in a search
> on Google are always welcome :) I don't know where to begin looking
> for this kind of information.

The Python 2.3.5 bundled with MacOSX doesn't come with readline.
Download 2.5 (or if you must 2.4) for the Mac from www.python.org and
live happily ever after.

E.g. (I'm hitting an up-arrow the 2nd time, then control-D next time):

brain:~ alex$ python2.3
Python 2.3.5 (#1, Jan 13 2006, 20:13:11) 
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 2+2
4
>>> ^[[A
  File "<stdin>", line 1
    ^
SyntaxError: invalid syntax
>>> ^D
brain:~ alex$ python2.4
Python 2.4.3 (#1, Apr  7 2006, 10:54:33) 
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 2+2
4
>>> 2+2
4
>>> 
brain:~ alex$ 


Alex



More information about the Python-list mailing list