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_
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
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,
"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
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
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
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
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
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
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
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
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
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
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
--- 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
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
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.
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 ()
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
*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
*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
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
*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
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
many many thanks to each and everyone who bothered to answer my op.
best regards
macs
--
http://mail.python.org/mailman/listinfo/python-list
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
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'
>>&
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
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
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()
>>>
"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
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
32 matches
Mail list logo