[Python-Dev] ABCs and MRO

Paul Moore p.f.moore at gmail.com
Wed Mar 4 14:17:13 CET 2009

2009/3/3 Jeffrey Yasskin <jyasskin at gmail.com>:
> 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:

    def foo(x, y):
        if isinstance(x, Iterable):
            do iterable processing
            do standard base processing

    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.


More information about the Python-Dev mailing list