Re: Descriptor: class name precedence over instance name

2016-07-03 Thread Veek. M
Ian Kelly wrote: > On Sat, Jul 2, 2016 at 3:34 AM, Veek. M wrote: >> So essentially from what Ian said: >> data_descriptor_in_instance -> instance_attribute -> non- >> data_descriptor_in_instance -->__mro__ >> >> is how the search takes place. Correct? > > Close, but I would write it as: > data_

Re: Descriptor: class name precedence over instance name

2016-07-02 Thread Ian Kelly
On Sat, Jul 2, 2016 at 3:34 AM, Veek. M wrote: > So essentially from what Ian said: > data_descriptor_in_instance -> instance_attribute -> non- > data_descriptor_in_instance -->__mro__ > > is how the search takes place. Correct? Close, but I would write it as: data_descriptor_in_class_including_m

Re: Descriptor: class name precedence over instance name

2016-07-02 Thread Veek. M
me and mounts my head on a pike - page 127 - Descriptors section, last para. He says that descriptor-attribute-names in a class, take precedence in a attribute lookup wrt instance attributes. When you do an x.a, python goes on a hunt for 'a' - the whole binding idea; typically, that is,

Re: Descriptor: class name precedence over instance name

2016-07-01 Thread Ben Finney
"Veek. M" writes: > Trying to make sense of this para: At the risk of being ruse, I am trying to make sense of some paragraphs in the messages you write here. Could you take a little more time to write clearly, as a way of communicating in this forum? > Is he say that Descriptors are a special

Re: Descriptor: class name precedence over instance name

2016-07-01 Thread Ian Kelly
On Fri, Jul 1, 2016 at 10:27 PM, Veek. M wrote: > Trying to make sense of this para: > > -- > Also, the attribute name used by the class to hold a descriptor takes > prece- dence over attributes stored on instances. > > In the previous example, > thi

Descriptor: class name precedence over instance name

2016-07-01 Thread Veek. M
Trying to make sense of this para: -- Also, the attribute name used by the class to hold a descriptor takes prece- dence over attributes stored on instances. In the previous example, this is why the descriptor object takes a name parameter and why

Re: how to get a class instance name during creation?

2008-10-04 Thread Ben Finney
dmitrey <[EMAIL PROTECTED]> writes: > On Oct 3, 9:46 pm, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: > > x = MyClass() > > y = x > > del x > > > > objects = [MyClass() for i in range(100)] > > > > If you can come with a meaningfull answer to "what's *the* name of > > any of the MyClass instan

Re: how to get a class instance name during creation?

2008-10-04 Thread dmitrey
On Oct 3, 9:46 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > dmitrey a écrit : > > > hi all, > > I have a code > > z = MyClass(some_args) > > can I somehow get info in MyClass __init__ function that user uses "z" > > as name of the variable? > > > I.e. to have __init__ function that creates

Re: how to get a class instance name during creation?

2008-10-03 Thread Aaron "Castironpi" Brady
On Oct 3, 1:46 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > dmitrey a écrit : > > > hi all, > > I have a code > > z = MyClass(some_args) > > can I somehow get info in MyClass __init__ function that user uses "z" > > as name of the variable? > > > I.e. to have __init__ function that creates

Re: how to get a class instance name during creation?

2008-10-03 Thread Bruno Desthuilliers
dmitrey a écrit : hi all, I have a code z = MyClass(some_args) can I somehow get info in MyClass __init__ function that user uses "z" as name of the variable? I.e. to have __init__ function that creates field z.name with value "z". This has been debated to hell and back. To make a long story s

Re: how to get a class instance name during creation?

2008-10-03 Thread Gabriel Genellina
En Fri, 03 Oct 2008 15:04:01 -0300, dmitrey <[EMAIL PROTECTED]> escribió: I have a code z = MyClass(some_args) can I somehow get info in MyClass __init__ function that user uses "z" as name of the variable? I.e. to have __init__ function that creates field z.name with value "z". No. I'd jus

how to get a class instance name during creation?

2008-10-03 Thread dmitrey
hi all, I have a code z = MyClass(some_args) can I somehow get info in MyClass __init__ function that user uses "z" as name of the variable? I.e. to have __init__ function that creates field z.name with value "z". Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list

Re: Get the instance name from a list by Reflection

2007-10-22 Thread jon vspython
May be, you could check against globals() dictionary looking for matching id()'s: def find_name(identifier): for k,v in globals().items(): if id(v) == id(identifier): return k -- http://mail.python.org/mailman/listinfo/python-list

Re: Get the instance name from a list by Reflection

2007-10-22 Thread Larry Bates
Jean-Paul Calderone wrote: > On Sat, 20 Oct 2007 21:10:34 +0200 (CEST), sccs cscs <[EMAIL PROTECTED]> > wrote: >> Hello, >> I cannot find into documentation how to get the instance name. I found >> the attributes __dict__,__class__ ,__bases__ __name__ , >> b

Re: Get the instance name from a list by Reflection

2007-10-22 Thread Gabriel Genellina
--- sccs cscs <[EMAIL PROTECTED]> escribió: > Thank you, but i believe that i could get all > variables names that reference an instance: i need > it for a special debug tool... It seems that > knowledge exists somewhere into the Python > interpreter... Please read first the FAQ item posted prev

Re: Get the instance name from a list by Reflection

2007-10-20 Thread Gabriel Genellina
En Sat, 20 Oct 2007 16:10:34 -0300, sccs cscs <[EMAIL PROTECTED]> escribi�: > I cannot find into documentation how to get the instance name. I found > the attributes __dict__,__class__ ,__bases__ __name__ , > but if i have the code: In general, you can't. There is n

Re: Get the instance name from a list by Reflection

2007-10-20 Thread Carsten Haese
On Sat, 2007-10-20 at 21:10 +0200, sccs cscs wrote: > Hello, > I cannot find into documentation how to get the instance name. That's because this is, in general, impossible. An object can have any number of names, even zero names, and an object doesn't know which names it has.

Re: Get the instance name from a list by Reflection

2007-10-20 Thread Jean-Paul Calderone
On Sat, 20 Oct 2007 21:10:34 +0200 (CEST), sccs cscs <[EMAIL PROTECTED]> wrote: >Hello, >I cannot find into documentation how to get the instance name. I found the >attributes __dict__,__class__ ,__bases__ __name__ , >but if i have the code: > >class A :pass >a1 = A ()

Get the instance name from a list by Reflection

2007-10-20 Thread sccs cscs
Hello, I cannot find into documentation how to get the instance name. I found the attributes __dict__,__class__ ,__bases__ __name__ , but if i have the code: class A :pass a1 = A () a2 = A () aList = [a1,a2] for elem in aList : print elem.__instance_name__ ??? I expect to have "a1

Re: Introspection Class/Instance Name

2006-04-26 Thread robert
*binarystar* wrote: > Hello there, > > what method would you use to return the name of the class and/or > instance introspectively eg. > > class Bollocks: > > def __init__( self ): > > print self.__method_that_returns_class_name__() > print self.__method_that_ret

Re: Introspection Class/Instance Name

2006-04-26 Thread Duncan Booth
*binarystar* wrote: > class Bollocks: > > def __init__( self ): > > print self.__method_that_returns_class_name__() > print self.__method_that_returns_instance_name__() > > > instance_of_bollocks = Bollocks() > > # Which outputs > > 'Bollocks' > 'i

Re: Introspection Class/Instance Name

2006-04-26 Thread [EMAIL PROTECTED]
What about: py> class A: py. def __init__(self): py. print self.__class__.__name__ py. print str(self) py. def __str__(self): py. return 'instance of %s' % self.__class__.__name__ py. py> a = A() A instance of A py> -- http://mail.python.org/mailman/l

Re: Introspection Class/Instance Name

2006-04-25 Thread Roland Heiber
*binarystar* wrote: > Hello there, > > what method would you use to return the name of the class and/or > instance introspectively eg. > > class Bollocks: > > def __init__( self ): > > print self.__method_that_returns_class_name__() > print self.__method_that_ret

Introspection Class/Instance Name

2006-04-25 Thread *binarystar*
Hello there, what method would you use to return the name of the class and/or instance introspectively eg. class Bollocks: def __init__( self ): print self.__method_that_returns_class_name__() print self.__method_that_returns_inst

Re: instance name

2005-04-05 Thread max(01)*
many many thanks to each and everyone who bothered to answer my op. best regards macs -- http://mail.python.org/mailman/listinfo/python-list

Re: instance name

2005-04-02 Thread Bengt Richter
On Sat, 02 Apr 2005 15:48:21 GMT, "max(01)*" <[EMAIL PROTECTED]> wrote: >hi. > >is there a way to define a class method which prints the instance name? > >e.g.: > > >>> class class_1: >... def myName(self): >... what

Re: instance name

2005-04-02 Thread Mark Winrock
max(01)* wrote: hi. is there a way to define a class method which prints the instance name? e.g.: >>> class class_1: ... def myName(self): ... what should i do here ... >>> instance_1 = class_1() >>> instance_1.myName() 'instance_1' >>&

Re: instance name

2005-04-02 Thread max(01)*
Irmen de Jong wrote: max(01)* wrote: hi. is there a way to define a class method which prints the instance name? e.g.: class class_1: ... def myName(self): ... what should i do here ... instance_1 = class_1() instance_1.myName() 'instance_1' bye macs What should the fo

Re: instance name

2005-04-02 Thread max(01)*
Andrew Koenig wrote: "max(01)*" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] is there a way to define a class method which prints the instance name? The term "the instance name" is misleading, because it assumes, without saying so explicitly, that e

Re: instance name

2005-04-02 Thread Irmen de Jong
max(01)* wrote: > hi. > > is there a way to define a class method which prints the instance name? > > e.g.: > >>>> class class_1: > ... def myName(self): > ... what should i do here > ... >>>> instance_1 = class_1() >>>

Re: instance name

2005-04-02 Thread Andrew Koenig
"max(01)*" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > is there a way to define a class method which prints the instance name? The term "the instance name" is misleading, because it assumes, without saying so explicitly, that every instance has a

instance name

2005-04-02 Thread max(01)*
hi. is there a way to define a class method which prints the instance name? e.g.: >>> class class_1: ... def myName(self): ... what should i do here ... >>> instance_1 = class_1() >>> instance_1.myName() 'instance_1' >>> bye macs -- http://mail.python.org/mailman/listinfo/python-list