rlcompleter and wxPython, problems ...

Stef Mientki stef.mientki at gmail.com
Sun Sep 28 18:25:30 EDT 2008


hello,

I'm trying to implement autocompletion into my editor.
But I find some weird behavior,
or at least I don't have the faintest  idea why  this behavior occures,
and even more important how to solve it
In the example below I try to autocomplete  " wx.s" , which in my humble 
opinion should at least produce "wx.stc"  (and some others ).

The completion is done in a procedure, so the "locals"  is quite clean.
Before calling the completer, I import the left part of my string to be 
completed.
The program below gives indeed "wx.stc"  as an option,
but if I leave the second line out, marker  "<<<===" ,
I get no results.

Can someone explain this behavior and
maybe even have a solution ?

thanks,
Stef Mientki


import rlcompleter
import wx.stc   # <<<===

# ***********************************************************************
# ***********************************************************************
def _get_completions ( word ) :
  left_part  = None
  right_part = word
  if word.find('.') >= 0 :
    word_parts = word.split('.')
    left_part = '.'.join ( word_parts [ : -1 ] )
    right_part = word_parts [ -1 ]

  try :
    exec ( 'import ' + left_part )
  except :
    return None

  Completer = rlcompleter.Completer ( locals () )
  State = 0
  Next = Completer.complete ( word, State )
  result = []
  while Next :
    result.append ( Next )
    State  += 1
    Next = Completer.complete ( word, State )

  result = ' '.join ( result )
  return result
# ***********************************************************************


# ***********************************************************************
# ***********************************************************************
if __name__ == "__main__":

  word = 'wx.s'
  completions = _get_completions ( word )
  print completions
# *******************************************************




More information about the Python-list mailing list