Can't extend function type
Paul Rubin
http
Fri Oct 7 09:50:11 EDT 2005
"Diez B. Roggisch" <deets at nospam.web.de> writes:
> Well - function inheritance is not known so far in python - and in no
> other language I know.
Yeah, I didn't really expect it to work, but it seems like a logical
consequence of type/class unification.
> Basically you want __mult__ being part of f or g when python
> encounters something like this
>
> f * g
>
> But then how did you plan to declare f?
Come to think of it, that's also a wart. I'd been thinking of
using a decorator, as Christopher Subich suggested,
@composable
def f(x): ...
but it's not how the decorator could actually work (other than through
gross CPython-specific hacks).
> So the only way to achieve this with current semantics is to make f
> anf g objects with a call methods. In that very moment, you're done -
> as extending from object is no problem :)
Yeah, I thought of that, but felt it wasn't in the proper spirit :)
More information about the Python-list
mailing list