Polymorphism

holger krekel pyth at devel.trillke.net
Tue Aug 6 01:35:33 CEST 2002


I forgot to mention that you should better test
your code before you post it ...

[me]
> dispatch_dict = {
>     int : HandleInt,
>     str : HandleStr,
>     list : HandleList
>     }
> 
> def polymorphic_func(arg, *otherargs):
>     return dispatch_dict(type(arg)) (*otherargs)

def polymorphic_func(arg, *otherargs):
    return dispatch_dict[type(arg)] (*otherargs)

of-course'ly yours,
    
    holger




More information about the Python-list mailing list