By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,767 Members | 1,334 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,767 IT Pros & Developers. It's quick & easy.

InteractiveConsole History on Linux

P: n/a
Why does code.InteractiveConsole support command history on Windows, but
not in a Gnome terminal (all I get is ^[[A^[[B)? Or does it not support
history at all, and the Windows console is implementing it's own? Is
there any way to get command history working with InteractiveConsole on
Linux?

Chris
Jul 15 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Why does code.InteractiveConsole support command history on Windows, but
not in a Gnome terminal (all I get is ^[[A^[[B)? Or does it not support
history at all, and the Windows console is implementing it's own? Is
there any way to get command history working with InteractiveConsole on
Linux?
The only time I see [A[B on Linux in a console is when I am not logged
in. Check to see if you're logged in and then try again. AFAIK, Linux
does support console history. I hope this helps :)

Jul 15 '06 #2

P: n/a

vbgunz wrote:
Why does code.InteractiveConsole support command history on Windows, but
not in a Gnome terminal (all I get is ^[[A^[[B)? Or does it not support
history at all, and the Windows console is implementing it's own? Is
there any way to get command history working with InteractiveConsole on
Linux?

The only time I see [A[B on Linux in a console is when I am not logged
in. Check to see if you're logged in and then try again. AFAIK, Linux
does support console history. I hope this helps :)
Sorry, I missed "code.InteractiveConsole" *but* maybe being logged in
has something to do with it?

Jul 15 '06 #3

P: n/a
Chris Spencer wrote:
Why does code.InteractiveConsole support command history on Windows, but
not in a Gnome terminal (all I get is ^[[A^[[B)? Or does it not support
history at all, and the Windows console is implementing it's own? Is
there any way to get command history working with InteractiveConsole on
Linux?
Be sure that the readline module is installed.

--
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

Jul 15 '06 #4

P: n/a
vbgunz wrote:
vbgunz wrote:
>>Why does code.InteractiveConsole support command history on Windows, but
not in a Gnome terminal (all I get is ^[[A^[[B)? Or does it not support
history at all, and the Windows console is implementing it's own? Is
there any way to get command history working with InteractiveConsole on
Linux?
The only time I see [A[B on Linux in a console is when I am not logged
in. Check to see if you're logged in and then try again. AFAIK, Linux
does support console history. I hope this helps :)

Sorry, I missed "code.InteractiveConsole" *but* maybe being logged in
has something to do with it?
Heh, how could I run Python if I weren't logged in :P
Jul 16 '06 #5

P: n/a
Robert Kern wrote:
Chris Spencer wrote:
>Why does code.InteractiveConsole support command history on Windows,
but not in a Gnome terminal (all I get is ^[[A^[[B)? Or does it not
support history at all, and the Windows console is implementing it's
own? Is there any way to get command history working with
InteractiveConsole on Linux?

Be sure that the readline module is installed.
Yeah, "import readline" works just fine. My problem isn't hard to
replicate. Can anyone else on Linux get command history to work with the
following code? Note, it should be saved and run from a file.

from code import InteractiveConsole
i = InteractiveConsole(globals())
i.interact()
Jul 16 '06 #6

P: n/a
Chris Spencer wrote:
Robert Kern wrote:
>Chris Spencer wrote:
>>Why does code.InteractiveConsole support command history on Windows,
but not in a Gnome terminal (all I get is ^[[A^[[B)? Or does it not
support history at all, and the Windows console is implementing it's
own? Is there any way to get command history working with
InteractiveConsole on Linux?
Be sure that the readline module is installed.

Yeah, "import readline" works just fine. My problem isn't hard to
replicate. Can anyone else on Linux get command history to work with the
following code? Note, it should be saved and run from a file.

from code import InteractiveConsole
i = InteractiveConsole(globals())
i.interact()
You will also have to make sure that you import readline, too. This works for me:

import readline
from code import InteractiveConsole
i = InteractiveConsole(globals())
i.interact()

--
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

Jul 16 '06 #7

P: n/a
Robert Kern wrote:
Chris Spencer wrote:
>Robert Kern wrote:
>>Chris Spencer wrote:
Why does code.InteractiveConsole support command history on Windows,
but not in a Gnome terminal (all I get is ^[[A^[[B)? Or does it not
support history at all, and the Windows console is implementing it's
own? Is there any way to get command history working with
InteractiveConsole on Linux?
Be sure that the readline module is installed.

Yeah, "import readline" works just fine. My problem isn't hard to
replicate. Can anyone else on Linux get command history to work with
the following code? Note, it should be saved and run from a file.

from code import InteractiveConsole
i = InteractiveConsole(globals())
i.interact()

You will also have to make sure that you import readline, too. This
works for me:

import readline
from code import InteractiveConsole
i = InteractiveConsole(globals())
i.interact()
Actually, it seems redirecting sys.stdout for my logger was the issue.
Thanks for your help though.

Chris
Jul 16 '06 #8

P: n/a

ChrisYeah, "import readline" works just fine. My problem isn't hard to
Chrisreplicate. Can anyone else on Linux get command history to work
Chriswith the following code? Note, it should be saved and run from a
Chrisfile.

Command history across sessions or just command recall from the current
session? On my Mac your script works just fine for me (no import readline
as Robert Kern indicated in his reply) to do command recall from the the
current session, but more is needed if you expect to get command history
across sessions.

Skip
Jul 16 '06 #9

P: n/a
sk**@pobox.com wrote:
ChrisYeah, "import readline" works just fine. My problem isn't hard to
Chrisreplicate. Can anyone else on Linux get command history to work
Chriswith the following code? Note, it should be saved and run from a
Chrisfile.

Command history across sessions or just command recall from the current
session? On my Mac your script works just fine for me (no import readline
as Robert Kern indicated in his reply) to do command recall from the the
current session, but more is needed if you expect to get command history
across sessions.
I was just looking for recall in the current session, although the
stdlib docs have an example of recall across sessions (
http://docs.python.org/lib/readline-example.html ).

On Linux, it seems you have to explicitly import readline in order to
get command history, although my application was also redirecting
sys.stdout, which was also causing problems.
Jul 16 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.