Re: [Tutor] class awareness of variable name

2007-09-18 Thread O.R.Senthil Kumaran
* Alan Gauld <[EMAIL PROTECTED]> [2007-09-17 18:54:43]: > If you go with the flow rather than trying to make the flow > go the way you want life is easier. Insightful. QOTW. :-) -- O.R.Senthil Kumaran http://uthcode.sarovar.org ___ Tutor maillist -

Re: [Tutor] class awareness of variable name

2007-09-17 Thread Alan Gauld
"Eric Abrahamsen" <[EMAIL PROTECTED]> wrote > to do it. I was thinking of cleaner ways of giving an instance a > 'name' attribute than > > instance_name = Class('instance_name') The thing is that you shouldn't even try! The object can have a name and that name will be constant regardless of which

Re: [Tutor] class awareness of variable name

2007-09-17 Thread Eric Abrahamsen
> This is pretty hard. For one thing, the object will not be bound to > a name until after __init__() is finished. Ah, that's a good thing to know... > you could probably use the stack frame to find the point of call > and inspect the byte codes there to find the name... I was afraid the ans

Re: [Tutor] class awareness of variable name

2007-09-17 Thread Kent Johnson
Eric Abrahamsen wrote: > When instantiating a class, is it possible for that instance to > 'know' (via the __init__ method, I suppose) the name of the variable > it's been assigned to? This is pretty hard. For one thing, the object will not be bound to a name until after __init__() is finishe

Re: [Tutor] class awareness of variable name

2007-09-17 Thread Eric Abrahamsen
On Sep 17, 2007, at 7:21 PM, Alan Gauld wrote: > > "Eric Abrahamsen" <[EMAIL PROTECTED]> wrote > >> When instantiating a class, is it possible for that instance to >> 'know' (via the __init__ method, I suppose) the name of the variable >> it's been assigned to? > > > Presumably you have a reason

Re: [Tutor] class awareness of variable name

2007-09-17 Thread Alan Gauld
"Eric Abrahamsen" <[EMAIL PROTECTED]> wrote > When instantiating a class, is it possible for that instance to > 'know' (via the __init__ method, I suppose) the name of the variable > it's been assigned to? You could pass it in as a string but there is little point. Recall that in Python variable

[Tutor] class awareness of variable name

2007-09-17 Thread Eric Abrahamsen
When instantiating a class, is it possible for that instance to 'know' (via the __init__ method, I suppose) the name of the variable it's been assigned to? Thanks E ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor