Checking object types

Robert Dailey rcdailey at
Wed Aug 1 19:12:41 CEST 2007


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: <>

More information about the Python-list mailing list