docstr: 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)
docstr_tok: ["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",")"]
code: def __init__(self, namespace=None):
      """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)
      """
  
      if namespace and not isinstance(namespace, dict):
          raise TypeError("namespace must be a dictionary")
  
      # Don't bind to namespace quite yet, but flag whether the user wants a
      # specific namespace or to use __main__.__dict__. This will allow us
      # to bind to __main__.__dict__ at completion time, not now.
      if namespace is None:
          self.use_main_ns = 1
      else:
          self.use_main_ns = 0
          self.namespace = namespace
  
file_path: cpython/Lib/rlcompleter.py
imports: import atexit
  import builtins
  import inspect
  import keyword
  import re
  import __main__
label_desc: Use image node_id 1 to create a new Completer object  with example: obj = Completer(namespace)