Module Expr Str Import alias Import alias Assign NameStore ListLoad Str ClassDef bases body FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If BoolOpAnd NameLoad UnaryOpNot Call NameLoad NameLoad NameLoad body Raise NameLoad Str If CompareIs NameLoad NameLoad body Assign AttributeStore NameLoad attr Num orelse Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If AttributeLoad NameLoad attr body Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr If CompareEq NameLoad Num body If CompareIn Str NameLoad body Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad orelse Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad TryExcept body Return SubscriptLoad AttributeLoad NameLoad attr Index NameLoad handlers ExceptHandler type NameLoad body Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body If Call NameLoad NameLoad Str body Assign NameStore BinOpAdd NameLoad Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Import alias Assign NameStore ListLoad Assign NameStore Call NameLoad NameLoad For NameStore AttributeLoad NameLoad attr body If CompareEq SubscriptLoad NameLoad Slice NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad For NameStore ListLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr body For TupleStore NameStore NameStore Call AttributeLoad NameLoad attr body If BoolOpAnd CompareEq SubscriptLoad NameLoad Slice NameLoad NameLoad CompareNotEq NameLoad Str body Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Import alias Assign NameStore Call AttributeLoad NameLoad attr Str NameLoad If UnaryOpNot NameLoad body Return ListLoad Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Num Num TryExcept body Assign NameStore Call NameLoad NameLoad AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Return ListLoad Assign NameStore Call NameLoad NameLoad If CompareIn Str NameLoad body Expr Call AttributeLoad NameLoad attr Str If Call NameLoad NameLoad Str body Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Assign NameStore ListLoad Assign NameStore Call NameLoad NameLoad For NameStore NameLoad body If BoolOpAnd CompareEq SubscriptLoad NameLoad Slice NameLoad NameLoad Call NameLoad NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad BinOpMod Str TupleLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call NameLoad NameLoad If Call NameLoad NameLoad Str body For NameStore AttributeLoad NameLoad attr body Assign NameStore BinOpAdd NameLoad Call NameLoad NameLoad Return NameLoad decorator_list TryExcept body Import alias handlers ExceptHandler type NameLoad body Pass orelse Expr Call AttributeLoad NameLoad attr AttributeLoad Call NameLoad attr
N/A N/A Word completion for GNU readline 2.0.

This requires the latest extension to the readline module. The completer
completes keywords, built-ins and globals in a selectable namespace (which
defaults to __main__); when completing NAME.NAME..., it evaluates (!) the
expression up to the last dot and completes its attributes.

It's very cool to do "import sys" type "sys.", hit the
completion key (twice), and see the list of names defined by the
sys module!

Tip: to use the tab key as the completion key, call

    readline.parse_and_bind("tab: complete")

Notes:

- Exceptions raised by the completer function are *ignored* (and
generally cause the completion to fail).  This is a feature -- since
readline sets the tty device in raw (or cbreak) mode, printing a
traceback wouldn't work well without some complicated hoopla to save,
reset and restore the tty state.

- The evaluation of the NAME.NAME... form may cause arbitrary
application defined code to be executed if an object with a
__getattr__ hook is found.  Since it is the responsibility of the
application (or the user) to enable this feature, I consider this an
acceptable risk.  More complicated expressions (e.g. function calls or
indexing operations) are *not* evaluated.

- GNU readline is also used by the built-in functions input() and
raw_input(), and thus these also benefit/suffer from the completer
features.  Clearly an interactive application can benefit by
specifying its own completer function and using raw_input() for all
its input.

- When the original stdin is not a tty device, GNU readline is never
used, and this module (and the readline module) are silently inactive.

 N/A __builtin__ N/A __main__ N/A __all__ N/A Completer Completer N/A N/A __init__ N/A N/A self namespace N/A None N/A N/A Create a new completer for the command line.

        Completer([namespace]) -> completer instance.

        If unspecified, the default namespace where completions are performed
        is __main__ (technically, __main__.__dict__). Namespaces should be
        given as dictionaries.

        Completer instances should be used as the completion mechanism of
        readline via the set_completer() call:

        readline.set_completer(Completer(my_namespace).complete)
         N/A N/A namespace N/A N/A isinstance namespace dict N/A N/A TypeError namespace must be a dictionary N/A N/A namespace None N/A N/A N/A self use_main_ns 1 N/A N/A N/A self use_main_ns 0 N/A N/A self namespace namespace N/A complete N/A N/A self text state N/A N/A N/A Return the next possible completion for 'text'.

        This is called successively with state == 0, 1, 2, ... until it
        returns None.  The completion should begin with 'text'.

         N/A N/A self use_main_ns N/A N/A N/A self namespace N/A __main__ __dict__ N/A N/A state 0 N/A N/A N/A . text N/A N/A N/A self matches N/A N/A self attr_matches text N/A N/A N/A self matches N/A N/A self global_matches text N/A N/A N/A N/A N/A self matches N/A state N/A N/A N/A IndexError N/A N/A None N/A _callable_postfix N/A N/A self val word N/A N/A N/A N/A hasattr val __call__ N/A N/A word N/A word ( N/A word N/A global_matches N/A N/A self text N/A N/A N/A Compute matches when text is a simple name.

        Return a list of all keywords, built-in functions and names currently
        defined in self.namespace that match.

         N/A keyword N/A matches N/A N/A n N/A len text N/A word N/A keyword kwlist N/A N/A N/A N/A word N/A n text N/A N/A N/A N/A matches append word N/A nspace N/A N/A __builtin__ __dict__ N/A self namespace N/A N/A N/A word val N/A N/A nspace items N/A N/A N/A N/A N/A word N/A n text N/A word __builtins__ N/A N/A N/A N/A matches append N/A N/A self _callable_postfix val word N/A matches N/A attr_matches N/A N/A self text N/A N/A N/A Compute matches when text contains a dot.

        Assuming the text is of the form NAME.NAME....[NAME], and is
        evaluatable in self.namespace, it will be evaluated and its attributes
        (as revealed by dir()) are used as possible completions.  (For class
        instances, class members are also considered.)

        WARNING: this can still invoke arbitrary C code, if an object
        with a __getattr__ hook is evaluated.

         N/A re N/A m N/A N/A re match (\w+(\.\w+)*)\.(\w*) text N/A N/A m N/A N/A N/A N/A N/A expr attr N/A N/A m group 1 3 N/A N/A N/A thisobject N/A eval expr N/A self namespace N/A N/A N/A Exception N/A N/A N/A N/A words N/A dir thisobject N/A N/A __builtins__ words N/A N/A N/A N/A words remove __builtins__ N/A N/A hasattr thisobject __class__ N/A N/A N/A N/A words append __class__ N/A N/A N/A words extend N/A get_class_members N/A thisobject __class__ N/A matches N/A N/A n N/A len attr N/A word words N/A N/A N/A N/A N/A word N/A n attr N/A hasattr thisobject word N/A N/A val N/A getattr thisobject word N/A word N/A N/A self _callable_postfix val N/A %s.%s N/A expr word N/A N/A N/A matches append word N/A matches N/A N/A get_class_members N/A N/A klass N/A N/A N/A ret N/A dir klass N/A N/A hasattr klass __bases__ N/A N/A base N/A klass __bases__ N/A N/A ret N/A ret N/A get_class_members base N/A ret N/A N/A N/A N/A readline N/A N/A N/A ImportError N/A N/A N/A N/A N/A N/A readline set_completer N/A N/A Completer complete