getattr is use to get value of variable from python class #shorts

preview_player
Показать описание
The getattr() method returns the value of the named attribute of an object. If not found, it returns the default value provided to the function.
getattr() Parameters:
getattr() method takes multiple parameters:

object - object whose named attribute's value is to be returned
name - string that contains the attribute's name
default (Optional) - value that is returned when the named attribute is not found

if we don't provide any default value, when the named attribute is not found, it raises an AttributeError saying the object has no attribute.

If you found the video valuable, please leave a like and subscribe ❤️ It helps the channel grow and helps me pumping out more such content.

#Shorts #youtubeshorts #python #class #getattr
Рекомендации по теме