How to use dynamic properties? <-- Noob

Bruno Desthuilliers bruno.desthuilliers at websiteburo.com
Tue Jan 23 03:17:11 EST 2007


Sean Schertell a écrit :
> person.name = 'Joe'
> person.age = 20
> person.sex = 'm'
> 
> info_I_need = name
> 
> print person.info_I_need
> 
> # How can I make it print 'Joe' ?
> 

print getattr(person, "name")




More information about the Python-list mailing list