Function Details: vars
Description
Returns the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute.
Extended Description
The vars() function returns the __dict__ attribute of an object. If no argument is passed, it returns a dictionary representing the current local symbol table. This is equivalent to locals(). If an object is passed as an argument, the object must have a __dict__ attribute, or a TypeError will be raised. vars() is useful for introspection and debugging, allowing you to examine the attributes of an object.
Read More about vars from Python Documentation
Function Signature
vars(object: Optional[Any] = None) -> dict
Module: builtins
Parameters
Parameter List
- object: Optional[Any]
Return
Returns a dictionary representing the __dict__ attribute of the object, or the current local symbol table if no argument is given.
Return Type
dict
Output
Explanation
This example shows how vars() returns the __dict__ of an object, including dynamically added attributes.