[IPython-user] pyreadline, code.InteractiveConsole and tab completion on Windows
Tue Apr 7 14:11:33 CDT 2009
Jörgen Stenarson schrieb:
> Thomas Heller skrev:
>> [repost from c.l.p]
>> I have installed pyreadline, and get nice tab completion in
>> the normal interactive interpreter:
>> However, in 'code.interact()', the behaviour is different. Hitting TAB
>> at the top level works as before, but hitting TAB after entering 'sys.' for example
>> doesn't show any completions:
> I have put this question and an answer on launchpad
> Here's a copy of my answer:
> The problem is that the completer function from rlcompleter only looks
> at the original namespace i.e. __main__.__dict__. When doing
> code.interact a new __dict__ is created as the global namespace for that
> session. The following session shows one way around the problem:
Thanks. In the meantime I have also found this out, but did not yet post
a reply to my question for the archives.
Anyway, my problem's not really solved completely because now I have the next
one, sorry ;-).
My Python console isn't started in the usual way because my application is
a Windows application.
When a certain button is pressed in the GUI, a win32 console is allocated,
sys.std[in|out|err] are initialized to readers/writers that read and write to
from/to the corresponding console handles, and so on. Basically the code goes
sys.stdout = writer(windll.kernel32.GetStdHandle(-11))
sys.stderr = writer(windll.kernel32.GetStdHandle(-12))
sys.stdin = reader(windll.kernel32.GetStdHandle(-10))
from code import InteractiveConsole
console = InteractiveConsole(ns)
reader(handle) and writer(handle) are instances that read and write from/to
the console handles with the windll.kernel32.WriteConsole[A|W]()
and windll.kernel32.ReadConsoleW() windows functions.
So, is it possible to plug pyreadline into this system somehow?
More information about the IPython-user