table continued method description _exit_ (selftypevaluetbcalled when leaving context if an exception occurredtypevalueand tb have the exception typevalueand traceback information the primary use of the context management interface is to allow for simplified resource control on objects involving system state such as open filesnetwork connectionsand locks by implementing this interfacean object can safely clean up resources when execution leaves context in which an object is being used further details are found in "program structure and control flow object inspection and dir(the dir(function is commonly used to inspect objects an object can supply the list of names returned by dir(by implementing _dir_ (selfdefining this makes it easier to hide the internal details of objects that you don' want user to directly access howeverkeep in mind that user can still inspect the underlying _dict_ attribute of instances and classes to see everything that is defined lib fl ff