polymorphism w/out signatures?

Aahz aahz at pythoncraft.com
Fri May 7 01:22:59 EDT 2004


In article <997a06e0.0405061128.6768676d at posting.google.com>,
 <pugnatio2 at yahoo.com> wrote:
>
>What's the standard way to implement polymorphic behavior in a python
>method, given that method arguments can't declare their types as
>they're being passed in, and method definitions don't have signatures?
>
>For instance, if I wanted to write a method that auto-detected whether
>it was being passed a string or a tuple/list, how would I do so
>without using type() to identify the parameter's type? Using type() is
>deprecated in the documentation I've read.

Generally speaking, in Python you simply create two different callables.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Adopt A Process -- stop killing all your children!



More information about the Python-list mailing list