Q: attribute access and comparisons of two different objects
Chris...
chris.schaller at web.de
Wed Jun 16 13:57:52 EDT 2004
aahz at pythoncraft.com (Aahz) wrote in message news:<cangqq$33i$1 at panix3.panix.com>...
> >1) Is there already a "fix" to avoid writing to an attribute that
> >isn't defined yet? I remember this being an often discussed problem,
> >but didn't see any changes. The only way I can think of is overriding
> >__setattr__, but this is huge overhead. While I like the idea of
> >being able to add new attributes on the fly, in great projects I'd
> >like to restrict some classes not to do so.
>
> Don't use __slots__. Why do you think __setattr__ is a huge overhead?
Ok, I won't use __slots__. I was trying it anway and found out that
it doesn't satisfy my needs. I do not like the idea of implementing
__setattr__ either. For each class I have to write my own __setattr__
which has to look up a class attribute like __attributes__ = ['attr1',
'attr2']. But I have to write it for each new class, right?
- Chris
More information about the Python-list
mailing list