Hrvoje Niksic a écrit :
> Bruno Desthuilliers <[EMAIL PROTECTED]>
> writes:
>
>>> However, if you know what you're doing, you can simply customize your
>>> class's __getattribute__ to do what *you* want for your objects.
>>
>> But bear in mind that, beside possible unwanted side-effectn, you'll
>
Bruno Desthuilliers <[EMAIL PROTECTED]>
writes:
>> However, if you know what you're doing, you can simply customize your
>> class's __getattribute__ to do what *you* want for your objects.
>
>
> But bear in mind that, beside possible unwanted side-effectn, you'll
> get a non-negligible performanc
andrew cooke a écrit :
> On Apr 15, 4:06 am, Bruno Desthuilliers [EMAIL PROTECTED]> wrote:
>
>> The canonical solution is to use a custom descriptor instead of a property:
(snip code)
> i tried code very similar after reading the first replies and found
> that it did not work as expected on setti
OK, fixed my bug - it does work. Now sleep... Thanks again, Andrew
--
http://mail.python.org/mailman/listinfo/python-list
ignore that - i was mistaken (my test was too complex).
the problem seems to be that the attribute is deleted even though
__delete__ is defined.
i'll look at it tomorrow.
thanks again,
andrew
On Apr 15, 4:50 am, andrew cooke <[EMAIL PROTECTED]> wrote:
> i tried code very similar after reading
On Apr 15, 4:06 am, Bruno Desthuilliers wrote:
> The canonical solution is to use a custom descriptor instead of a property:
>
> class Field(object):
>def __init__(self, name, onchange):
> self.name = name
> self.onchange = onchange
>
>def __get__(self, instance, cls):
> if
Hrvoje Niksic a écrit :
(snip)
> As others explained, descriptors are called for descriptors found in
> class attributes, not in ones in instance attributes.
(snip)
> However, if you know what you're doing, you can simply customize your
> class's __getattribute__ to do what *you* want for your o
andrew cooke a écrit :
> Hi,
>
> This is my first attempt at new classes and dynamic python, so I am
> probably doing something very stupid... After reading the how-to for
> descriptors at http://users.rcn.com/python/download/Descriptor.htm I
> decided I would make an object that returns attribut
andrew cooke <[EMAIL PROTECTED]> writes:
> This is my first attempt at new classes and dynamic python, so I am
> probably doing something very stupid... After reading the how-to for
> descriptors at http://users.rcn.com/python/download/Descriptor.htm I
> decided I would make an object that return
"Gabriel Genellina" <[EMAIL PROTECTED]> writes:
> The "magic" happens when the descriptor is found in the *class*, not
> in the instance. I think it's detailed in Hettinger's document.
The document is wrong here:
Alternatively, it is more common for a descriptor to be invoked
automatical
[Gabriel:]
> The "magic" happens when the descriptor is found in the *class*, not in
> the instance. I think it's detailed in Hettinger's document.
> Do you actually want "per-instance" defined properties?
ah! ok. yes, you're right: i want instance values but class
properties, so i'll rethink th
En Mon, 14 Apr 2008 22:43:39 -0300, andrew cooke <[EMAIL PROTECTED]>
escribió:
> This is my first attempt at new classes and dynamic python, so I am
> probably doing something very stupid... After reading the how-to for
> descriptors at http://users.rcn.com/python/download/Descriptor.htm I
> de
Hi,
This is my first attempt at new classes and dynamic python, so I am
probably doing something very stupid... After reading the how-to for
descriptors at http://users.rcn.com/python/download/Descriptor.htm I
decided I would make an object that returns attributes on read, but on
setting calls an
13 matches
Mail list logo