[IPython-user] Readline for Windows
Fernando Perez
Fernando.Perez at colorado.edu
Wed May 5 16:03:23 CDT 2004
Voidspace wrote:
> Found it :
...
> D:\PYTHON23\Lib\site-packages\IPython\iplib.py in
> __init__(self=<IPython.iplib.MagicCompleter instance at 0x00A59238>,
> namespace={'In': ['\n'], 'Out': {}, '__IP':
> <IPython.iplib.InteractiveShell instance at 0x009EFF58>, '__builtins__':
> <module '__builtin__' (built-in)>, '__name__': '__main__', '_dh':
> [r'H:\My Documents'], '_ih': ['\n'], '_oh': {}, 'help': Type help() for
> interactive help, or help(object) for help about object.}, omit__names=0)
> 86
> 87 class MagicCompleter(FlexCompleter.Completer):
> 88 """Extension of the completer class to work on
> @-prefixed lines."""
> 89
> 90 def __init__(self, namespace = None, omit__names = 0):
> 91 """MagicCompleter(namespace = None, omit__names = 0)
> -> completer
> 92
> 93 Return a completer object suitable for use by the
> readline library
> 94 via readline.set_completer().
> 95
> 96 The optional omit__names parameter sets the
> completer to omit the
> 97 'magic' names (__magicname__) for python objects
> unless the text
> 98 to be completed explicitly starts with one or more
> underscores."""
> 99
> 100 FlexCompleter.Completer.__init__(self,namespace)
> --> 101 delims = FlexCompleter.readline.get_completer_delims()
> delims = undefined, global FlexCompleter = <module
> 'IPython.FlexCompleter' from
> 'D:\Python23\Lib\site-packages\IPython\FlexCompleter.pyc'>, global
> readline = undefined, global get_completer_delims = undefined
> 102 delims = delims.replace('@','')
> 103 FlexCompleter.readline.set_completer_delims(delims)
> 104 self.omit__names = omit__names
> 105
> 106 # Code contributed by Alex Schmolck, for ipython/emacs
> integration
> 107 def all_completions(self, text):
> 108 """Return all possible completions for the benefit
> of emacs."""
> 109
> 110 completions = []
> 111 try:
> 112 for i in xrange(sys.maxint):
> 113 res = self.complete(text, i)
> 114
> 115 if not res: break
> 116
>
> AttributeError: 'module' object has no attribute 'get_completer_delims'
Well, I'm sorry to say this, but I think their readline is just broken: if
they want to implement a readline-like module for windows, it should hopefully
conform to the API of the standard python readline one. Otherwise, it becomes
a pain to maintain cross-platform code.
I _could_ put in a hackish try/except around various things which can make
this pseudo-readline crash, but I won't. I would rather argue that this
module should be called readline_win or somesuch until it is API-compatible
with the true python readline one. Making a module with the same name as one
in the standard library, but which implements only part of the API is just
nasty, IMHO. Note that I'm not implying any malice on the author's part, just
a poor coding/design choice; no offense intended.
>>I've googled - but can't find any reference to 'Gary Bishop's python
>>tools'... are they for cygwin python or 'real python' ? :-)
http://sourceforge.net/projects/uncpythontools/
Sorry for not posting a link before, since it's not that obvious unless you
knew what to google for in the first place ('uncpythontools').
Regards,
f
More information about the IPython-user
mailing list