empty classes as c structs?
Steven Bethard
steven.bethard at gmail.com
Tue Feb 8 02:04:50 EST 2005
Michael Spencer wrote:
> I see no problem in repeating the methods, or inheriting the
> implementation. However, if namespace and bunch are actually different
> concepts (one with reference semantics, the other with copy), then
> __repr__ at least would need to be specialized, to highlight the
> difference.
Yeah, I could certainly see them being separate... Of course, someone
else will have to write the PEP for Namespace then. ;)
> def __ge__(self, other):
> for attrname in other.__dict__.keys():
> if not attrname in self.__dict__:
> return False
> return True
>
> I realize that interfaces may be addressed formally by a current PEP,
> but, even if they are, this "cheap and cheerful" approach appeals to me
> for duck-typing.
>
> However, as I think more about this, I realize that I am stretching your
> concept past its breaking point, and that whatever the merits of this
> approach, it's not helping you with bunch. Thanks for knocking the
> ideas around with me.
My pleasure. It's good to talk some use-cases, and make sure I cover as
much as is feasible in the PEP. I think __ge__ is probably too far out
from the original intentions, but I'll make sure to write
Bunch/Namespace to be as inheritance-friendly as possible so that adding
such behavior by inheriting from Bunch/Namespace should be simple.
Thanks for all your comments!
Steve
More information about the Python-list
mailing list