Re: Getting the name of an assignment

2006-12-23 Thread Steven Bethard
Adam Atlas wrote: > Isn't it a bit convoluted to use metaclasses? Yep. It's a well known fact that putting "convoluted" and "metaclasses" in the same sentence is repetitively redundant. ;-) > someinstance.__class__.__name__ does the same thing. No, not really:: >>> class C(object): .

Re: Getting the name of an assignment

2006-12-23 Thread Adam Atlas
Thanks, Steven and Steven. @Bethard: Isn't it a bit convoluted to use metaclasses? someinstance.__class__.__name__ does the same thing. @D'Aprano: Thanks for the advice to rethink my data model. I'm doing so right now, and I've already come up with a way that makes more sense. :) -- http://mail

Re: Getting the name of an assignment

2006-12-23 Thread Steven Bethard
Adam Atlas wrote: > Is it possible for an object, in its __init__ method, to find out if it > is being assigned to a variable, and if so, what that variable's name > is? I can think of some potentially ugly ways of finding out using > sys._getframe, but if possible I'd prefer something less exotic.

Re: Getting the name of an assignment

2006-12-23 Thread Steven D'Aprano
On Sat, 23 Dec 2006 14:38:19 -0800, Adam Atlas wrote: > Is it possible for an object, in its __init__ method, to find out if it > is being assigned to a variable, and if so, what that variable's name > is? What should the variable name be set to if you do one of the following? john = eric = gr

Re: Getting the name of an assignment

2006-12-23 Thread Adam Atlas
On Dec 23, 5:58 pm, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > On 23 Dec 2006 14:38:19 -0800, Adam Atlas <[EMAIL PROTECTED]> wrote: > > > Is it possible for an object, in its __init__ method, to find out if it > > is being assigned to a variable, and if so, what that variable's name > > is? I c

Re: Getting the name of an assignment

2006-12-23 Thread BJörn Lindqvist
On 23 Dec 2006 14:38:19 -0800, Adam Atlas <[EMAIL PROTECTED]> wrote: > Is it possible for an object, in its __init__ method, to find out if it > is being assigned to a variable, and if so, what that variable's name > is? I can think of some potentially ugly ways of finding out using > sys._getframe

Getting the name of an assignment

2006-12-23 Thread Adam Atlas
Is it possible for an object, in its __init__ method, to find out if it is being assigned to a variable, and if so, what that variable's name is? I can think of some potentially ugly ways of finding out using sys._getframe, but if possible I'd prefer something less exotic. (Basically I have a class