empty classes as c structs?

Steven Bethard steven.bethard at gmail.com
Wed Feb 9 18:54:35 EST 2005


Alex Martelli wrote:
> Steven Bethard <steven.bethard at gmail.com> wrote:
> 
>>I didn't know what to do for __setattr__...  Was that what you meant by
>>"The best semantics for _bindings_ as opposed to lookups isn't clear 
>>though"?
> 
> Yep.  __delattr__ ain't too obvious to me either, though I guess your
> semantics for that are OK.

I'm not sure how much _I_ like them... =) It makes me uneasy that

     del b.x
     print b.x

doesn't throw an AttributeError.  OTOH, if you're using namespaces as 
the equivalent of nested scopes, deleting all 'x' attributes is probably 
not what you want...

I like the idea of chain, though, so I'll probably add the class with 
just __init__ and __getattribute__ to the current implementation.  I'm 
willing to be persuaded, of course, but for the moment, since I can see 
a few different options, I'm refusing the temptation to guess on the 
"most natural" behavior for __delattr__ and __setattr__...  =)

Steve



More information about the Python-list mailing list