Re: [Tutor] names and variables

2008-08-20 Thread Kent Johnson
On Wed, Aug 20, 2008 at 5:37 AM, Marc Tompkins <[EMAIL PROTECTED]> wrote: > print(getattr(myObject, "colour")) Or, of course, print getattr(myObject, myAttribute) which is what the OP wanted. Kent ___ Tutor maillist - Tutor@python.org http://mail.pyt

Re: [Tutor] names and variables

2008-08-20 Thread Lie Ryan
On Wed, 2008-08-20 at 11:37 +0200, [EMAIL PROTECTED] wrote: > Message: 7 > Date: Wed, 20 Aug 2008 17:30:37 +0800 > From: Jim Morcombe <[EMAIL PROTECTED]> > Subject: [Tutor] names and variables > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Typ

Re: [Tutor] names and variables

2008-08-20 Thread Marc Tompkins
On Wed, Aug 20, 2008 at 2:30 AM, Jim Morcombe <[EMAIL PROTECTED]>wrote: > I have an object called "myObject" with an attribute called "colour". > > If I type: > print myObject.colour > then python prints: >red > > Now, I have a variable "myAttribute" and set its value to "colour" by > typin

[Tutor] names and variables

2008-08-20 Thread Jim Morcombe
I have an object called "myObject" with an attribute called "colour". If I type: print myObject.colour then python prints: red Now, I have a variable "myAttribute" and set its value to "colour" by typing: myAttribute = "colour" I want to have a line of code: something like this: