How to use dynamic properties? <-- Noob

Discussion in 'Python' started by Sean Schertell, Jan 23, 2007.

  1. 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
    Sean Schertell, Jan 23, 2007
    #1
    1. Advertising

  2. 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")
    Bruno Desthuilliers, Jan 23, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. NuclearFusion

    Noob: use of the double colon

    NuclearFusion, Mar 26, 2006, in forum: Ruby
    Replies:
    12
    Views:
    175
  2. whisperjim
    Replies:
    9
    Views:
    165
    Sam Howes
    Aug 31, 2009
  3. Micky Hulse

    OOP noob question: Mixin properties

    Micky Hulse, Dec 13, 2012, in forum: Python
    Replies:
    0
    Views:
    138
    Micky Hulse
    Dec 13, 2012
  4. Micky Hulse

    Re: OOP noob question: Mixin properties

    Micky Hulse, Dec 13, 2012, in forum: Python
    Replies:
    0
    Views:
    138
    Micky Hulse
    Dec 13, 2012
  5. Micky Hulse

    Re: OOP noob question: Mixin properties

    Micky Hulse, Dec 14, 2012, in forum: Python
    Replies:
    2
    Views:
    158
    Micky Hulse
    Dec 14, 2012
Loading...

Share This Page