Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python attributes from string

class Car : 
    color = "red"

# initializing object 
my_car = Car() 
  
# use of getattr 
print(getattr(my_car,"color"))
 
PREVIOUS NEXT
Tagged: #python #attributes #string
ADD COMMENT
Topic
Name
3+6 =