Panos Laganakos wrote:

> I want a class method to take action depending on the type of the
> arguement passed to it.
> 
> ie:
> getBook(id) # get the book by ID
> getBook(name) # get the book by name
> ...
> 
> Other languages use the term function/method overloading to cope with
> this. And when I googled about it seems that GvR is testing it for 3.0
> inclusion or so.
> 
> I was thinking of right after the function declaration check for the
> parameter passed by isinstance() or type() and use if..elif..else to
> act.
> 
> Is this the pythonic way/best practice to apply here?

google for gnosis multimethods for a clean approach.


Diez
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to