arrow keys don't work

T

tac-tics

I've noticed that in Python 2.5, the interactive prompt does not
support intelligent use of arrow keys like 2.4 did (up/down for
previous/next statement, left/right for moving the cursor). What
exactly is the reason for this and is there an easier fix than
downgradinig to 2.4? Thanks.
 
R

Robert Kern

tac-tics said:
I've noticed that in Python 2.5, the interactive prompt does not
support intelligent use of arrow keys like 2.4 did (up/down for
previous/next statement, left/right for moving the cursor). What
exactly is the reason for this and is there an easier fix than
downgradinig to 2.4? Thanks.

Your installation of 2.4 probably had the readline module installed while your
installation of 2.5 doesn't. What platform are you on?

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
T

tac-tics

Robert said:
Your installation of 2.4 probably had the readline module installed while your
installation of 2.5 doesn't. What platform are you on?

Actually, I should have posted this a while ago. I've noticed it on
Ubuntu Linux, Mac OSX, and earlier today on Sun Solaris.

What do I need to do to install / configure readline?
 
S

Steven D'Aprano

I've noticed that in Python 2.5, the interactive prompt does not
support intelligent use of arrow keys like 2.4 did (up/down for
previous/next statement, left/right for moving the cursor).

It works perfectly for me.
What
exactly is the reason for this and is there an easier fix than
downgradinig to 2.4? Thanks.

Have you changed your terminal (either the program itself or its config)
so that it is no longer sending the correct codes?

When you hit the arrow key, what happens? Do you just get nothing at all,
or do you get control characters appearing? e.g. ^Z or similar.
 
T

tac-tics

Have you changed your terminal (either the program itself or its config)
so that it is no longer sending the correct codes?

I doubt this is the case. Everything works for the bash shell and
common lisp. It's just python acting up.
When you hit the arrow key, what happens? Do you just get nothing at all,
or do you get control characters appearing? e.g. ^Z or similar.

udlr yields ^[[A^[[B^[[C^[[D in the interactive python interpreter, but
like I said, works like it should outside the Python interpreter.
 
T

Terry Reedy

|> Have you changed your terminal (either the program itself or its config)
| udlr yields ^[[A^[[B^[[C^[[D in the interactive python interpreter, but
| like I said, works like it should outside the Python interpreter.

If I remember correctly, '^[' represents the escape character and '^[[A',
etc represent the standard ANSI terminal escape sequences for the up, etc,
key. So you are missing the interpretive layer that should intercept and
act on those sequences and Python is getting them raw (literally).

tjr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top