On Wed, 14 Feb 2007 21:58:35 -0800, Paul McGuire wrote: > No, Python does not do overloading as part of the language, you have > to do the variable argument interpretation for yourself. > > For instance, if you want a method to accept a single argument of > various types, it would look something like this: > > def multiAccept( argOfVariousTypes ): > if isinstance(argOfVariousTypes,int): > # treat like an int > elif isinstance(argOfVariousTypes,float): > # treat like a float > elif isinstance(argOfVariousTypes,(list,tuple)): > # treat like a container
Is that really called "overloading"? I've never (knowingly) come across the term being used in that context before. I've always known that as "multiple dispatch" or "polymorphism", depending on whether you or the compiler handles the dispatching. Actually, I tell a lie. I've always know it as "a function that can handle different types of arguments" :) -- Steven D'Aprano -- http://mail.python.org/mailman/listinfo/python-list