Python vars() FunctionPython vars() function returns the __dict__ attribute of the given object. SignatureParametersobject (optional): It is an object and can be a module, class, instance, or any other object having __dict__ attribute. ReturnIt returns the __dict__ attribute of the given object. If any object fails to match the attribute, it raises a TypeError exception. Python vars() Function Example 1The below example shows the working of vars(). Output: {'y': 9, 'x': 7} Explanation: In the above example, we define a class named as Python and made InstanceOfPython of Python class and in return, it prints the __dict__ attribute of the x and y object. Next TopicPython Built in Functions |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India