Python getattr() Function for getting the value of a class attribute.

Charan H U
Oct 11, 2022

--

Python getattr() Function: The getattr() function returns the value of the specified attribute (property or method) from the specified object.

If the specified attribute does not exist, default value is returned.

Syntax: getattr(object, attribute, default)

Parameters:

object: object whose attribute is to be returned

attribute: attribute name whose value is to be returned

default: default value to be returned if the attribute does not exist

Return Value: value of the specified attribute

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Charan H U
Charan H U

Written by Charan H U

Applied AI Engineer | Internet Content Creator

No responses yet

Write a response