Language Syntax
Attribute reference — Python syntax
Resolve an attribute using the receiver's attribute-access mechanism, which may invoke descriptors or custom hooks. Dot syntax requires an identifier; getattr can use a computed string name.
Formal Syntax & Structure
python syntaxpython
object.attributeReturn Value
object
Value obtained by evaluating this expression; see description for context and constraints.
Working Example
Example Snippetpython
class Item: name='book'item=Item()print((item.name,getattr(item,'name')))