r wrote:
>here is what i have, it would seem stupid to use a conditional in each
>method like this...
>
>def method(self, other):
>if isinstance(other, Point2d):
>x, y = origin.x, origin.y
>else:
>x, y = origin[0], origin[1]
>#modify self.x & self.y with x&y
Here's an
On Jan 14, 8:50 am, r wrote:
> On Jan 14, 10:44 am, Steve Holden wrote:
>
> > Thous it does seem particularly perverse to have the add method not
> > itself return a Point.
>
> Thanks Steve,
> i was going implement exactly this but thought there "might" be a
> better way i did not know about. So
On Jan 14, 10:44 am, Steve Holden wrote:
> Thous it does seem particularly perverse to have the add method not
> itself return a Point.
Thanks Steve,
i was going implement exactly this but thought there "might" be a
better way i did not know about. So i feel better about myself
already. And your
r wrote:
> I am hacking up a point class but having problems with how to properly
> overload some methods. in the __add__, __sub__, __iadd__, __isub__, I
> want to have the option of passing an instance or a container(list,
> tuple) like
>
p1 = Point2d(10,10)
p1 += (10,10)
p1
> Poin
before anybody say's anything, i screwed up when i pasted the code,
here is what i really have...
def method(self, other):
if isinstance(other, Point2d):
x, y = other.x, other.y
else:
x, y = other[0], other[1]
return self.x+x, self.y+y
#and the fixed class :)
class Po