[Python-Dev] Class Methods
Alex Martelli
aleaxit at yahoo.com
Thu Apr 26 12:16:15 EDT 2001
"Thomas Heller" <thomas.heller at ion-tof.com> wrote in message
news:9c93cq$cisqv$1 at ID-59885.news.dfncis.de...
[snip]
> An alternative, of course, would be to use a factory function
> for classes:
>
> POINT = create_structure("POINT", names=("x", "y"), format="ii")
>
> but I would loose the (easy) ability to override or implement instance
> methods.
You wouldn't have to lose it, nor would it be hard, I think:
class POINT(create_structure("POINT_BASE", names=("x", "y"), format="ii")):
def additional_method(self):
print "Have your cake and inherit it too"
> Also: Does anyone expect the spani^H^H^H^H^H functions to create
> and return classes ?
Depends on there the function call is seen, I guess. Seeing it
among the base classes of some class should ring a bell:-).
> I've never seen (apart from demo/metaclasses) any use of Guido's
> hook.
I'm starting to wonder which one BPL uses (I _thought_ I
understood it, but then, I had NOT understood there were
two separate hooks around, so clearly I had not understood
correctly...).
[very interesting rest of discussion snipped]
Alex
More information about the Python-list
mailing list