Checking object types

Robert Dailey rcdailey at gmail.com
Wed Aug 1 13:12:41 EDT 2007


Hi,

I'm currently interested in creating an __add__() operator for one of my
classes. This class handles both integers and objects its own type, however
I don't know how I can perform special add operations depending on which is
passed in. Since I haven't seen any evidence of function overloading, I'm
assuming I'll have to check the types of the variables passed in inside of
my __add__() method.

Take the two following examples:

vector3(3,4,2) + 5 = vector3(8,9,7)
vector3(3,2,1) + vector3(4,5,6) = vector3(7,7,7)

Any tips? Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070801/41fd3771/attachment.html>


More information about the Python-list mailing list