Sean Schertell wrote:
> 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' ?
>
>
> Sean
>
>
> ::::  DataFly.Net  ::::
> Complete Web Services
> http://www.datafly.net
>
>   
Like this:

    info_I_need = 'name'

    print getattr(person, info_I_need)

Related to getattr are setattr and hasattr. 

Gary Herron




-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to