class_docstr: Context manager for dynamic management of a stack of exit callbacks
  
  For example:
  
      with ExitStack() as stack:
          files = [stack.enter_context(open(fname)) for fname in filenames]
          # All opened files will automatically be closed at the end of
          # the with statement, even if attempts to open files later
          # in the list raise an exception
class_docstr_tok: ["Context","manager","for","dynamic","management","of","a","stack","of","exit","callbacks","For","example",":","with","ExitStack","(",")","as","stack",":","files","=","[","stack.enter_context","(","open","(","fname",")",")","for","fname","in","filenames","]","#","All","opened","files","will","automatically","be","closed","at","the","end","of","#","the","with","statement",",","even","if","attempts","to","open","files","later","#","in","the","list","raise","an","exception"]
docstr: Registers a callback with the standard __exit__ method signature
  
  Can suppress exceptions the same way __exit__ methods can.
  
  Also accepts any object with an __exit__ method (registering a call
  to the method instead of the object itself)
docstr_tok: ["Registers","a","callback","with","the","standard","__exit__","method","signature","Can","suppress","exceptions","the","same","way","__exit__","methods","can",".","Also","accepts","any","object","with","an","__exit__","method","(","registering","a","call","to","the","method","instead","of","the","object","itself",")"]
code: def push(self, exit):
      """Registers a callback with the standard __exit__ method signature
  
      Can suppress exceptions the same way __exit__ methods can.
  
      Also accepts any object with an __exit__ method (registering a call
      to the method instead of the object itself)
      """
      # We use an unbound method rather than a bound method to follow
      # the standard lookup behaviour for special methods
      _cb_type = _get_type(exit)
      try:
          exit_method = _cb_type.__exit__
      except AttributeError:
          # Not a context manager, so assume its a callable
          self._exit_callbacks.append(exit)
      else:
          self._push_cm_exit(exit, exit_method)
      return exit
  
imports: import abc
  import sys
  import warnings
  from collections import deque
  from functools import wraps
label_desc: Use image node_id 4 for calling the ExitStack obj's underlying member method code with example usage: obj.push(exit) and returns: exit