2009/3/3 Jeffrey Yasskin <[email protected]>:
> Unfortunately, I think overloading functions on Number or Iterable
> would be really useful, and constraining it to only look at base
> classes would be unfortunate.
That could well be the case. So the question is, I guess, how would
you write such a function now? Because you could always continue to
write it like that, but make it generic for the other special cases
you didn't think of:
@simplegeneric
def foo(x, y):
if isinstance(x, Iterable):
do iterable processing
else:
do standard base processing
@foo.register(int)
def foo_int(x, y):
do int processing
It's unfortunate that you have to cover it in the base processing, but
certainly no worse than at present.
Paul.
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com