> > Does this mean that __setattr__
> > incurs the same performance penalty that overriding __getattribute__
> > would?
>
> Not quite AFAICT - there's less going on here. Also, getting an
> attribute is (usually at least) more common than setting it.
>
> > Possibly I can live with this because I th
[EMAIL PROTECTED] a écrit :
>> As a side note: the naming symetry between __getattr__ and __setattr__
>> is a gotcha, since __setattr__ is mostly symetric to __getattribute__ -
>> IOW, customizing __setattr__ is a bit tricky. The naive approach, ie:
>
> Ah I see - so __setattr__ is called immediat
> As a side note: the naming symetry between __getattr__ and __setattr__
> is a gotcha, since __setattr__ is mostly symetric to __getattribute__ -
> IOW, customizing __setattr__ is a bit tricky. The naive approach, ie:
Ah I see - so __setattr__ is called immediately whereas __getattr__ is
only cal
[EMAIL PROTECTED] a écrit :
> On Feb 6, 11:09 pm, "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>> While this is technically possible (I tried a couple years ago), it
>> requires hacking the __getattribute__ method, which is something I
>> would not recommand, not only because it can be tricky,
On Feb 6, 11:09 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> While this is technically possible (I tried a couple years ago), it
> requires hacking the __getattribute__ method, which is something I
> would not recommand, not only because it can be tricky, but mostly
> because this is a very
On Feb 6, 10:54 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> I'd suggest a small improvement: _A as a class name isn't very nice.
> Replace the inner class statement with:
> _A = type(self.__class__.__name__ + '_autoprops', (self.__class__,), {})
Ah yes, that's much nicer.
> A problem wit
On 6 fév, 21:06, [EMAIL PROTECTED] wrote:
> Hi all,
>
> So I understand that properties belong to a class not an instance, but
> nonetheless I want to add properties to an instance.
While this is technically possible (I tried a couple years ago), it
requires hacking the __getattribute__ method, wh
En Wed, 06 Feb 2008 18:06:48 -0200, <[EMAIL PROTECTED]>
escribió:
> So I understand that properties belong to a class not an instance, but
> nonetheless I want to add properties to an instance. I have a class
> which when an instance is created runs some fairly complicated code
> and produces a
Er, instead of "getattr(self,...) you gotta do
"object.__getattr__(self,...)" and same for setattr and delattr. Dumb error
on my part. (Otherwise you get infinite recursion!)
On Feb 6, 2008 12:43 PM, Jared Grubb <[EMAIL PROTECTED]> wrote:
> Here's one way of doing what you're asking... I would su
Here's one way of doing what you're asking... I would suggest using
__getattribute__ and __setattr__ to dispatch the methods to the custom class
you invent that holds all those properties.
For example (I simplified your makeprops into __init__ just to keep the
example short, but you can probably s
Hi all,
So I understand that properties belong to a class not an instance, but
nonetheless I want to add properties to an instance. I have a class
which when an instance is created runs some fairly complicated code
and produces a set of names which I'd like to be able to access via
properties. At
11 matches
Mail list logo