generic functions in python
Miki Tebeka
miki.tebeka at zoran.com
Sun May 30 04:22:51 EDT 2004
Hello Jim,
> E.g., the multiple class inheritance is great,
> but there are no generic functions (at least that
> i can find). If i have classes X, Y, and Z,
> and subclasses X_sub, Y_sub, and Z_sub respectively.
>
> I'd love to write methods which speicialize on pairs
> of these classes. It works in lisp as follows
>
> (defmethod mymethod (( x X) ( y Y)) ;; # 1
> ...)
>
> (defmethod mymethod (( x X_sub) ( y Y)) ;; # 2
> ...)
>
> (defmethod mymethod (( z Z) ( x X)) ;; # 3
> ..)
>
>
> Then for example if i call mymethod with
> an instance of X_sub and Y_sub then # 2
> gets called.
http://www-106.ibm.com/developerworks/linux/library/l-pydisp.html
HTH.
Miki.
More information about the Python-list
mailing list