Python getattr() function

The getattr() function in Python returns the value of the named attribute for the given object.



object: It is a required parameter which represents an object.

name: This parameter represents the name of the attribute you want to get the value from.

default: It represents the value to return if the attribute does not exist.


This function returns the value of the given attribute from the specified object.

Example 1


Pin It on Pinterest

Share This