[Tutor] FW: Can this be done easly

Roelof Wobben rwobben at hotmail.com
Sun Sep 19 21:05:03 CEST 2010




----------------------------------------
> From: andreengels at gmail.com
> Date: Sun, 19 Sep 2010 20:54:01 +0200
> Subject: Re: [Tutor] FW: Can this be done easly
> To: rwobben at hotmail.com
> CC: tutor at python.org
>
> On Sun, Sep 19, 2010 at 8:33 PM, Roelof Wobben wrote:
>
>> Hello,
>>
>> I changed the programm to this :
>>
>> import unittest
>> class Point:
>> def __init__(self, x=0, y=0):
>> self.x = x
>> self.y = y
>>
>> class Rectangle(object):
>> def __init__(self, base_point, width=0, length=0):
>> self.base_point = base_point
>> self.width = width
>> self.length = length
>>
>> def moverect(roelof, dx, dy):
>> roelof.base_point.y += dy
>> roelof.base_point.x +=dx
>> return roelof
>>
>> r = Rectangle(Point(3, 4), 20, 30)
>> moverect(r, 10, 11)
>> assert r.base_point.x == 13, "wrong x position %d" % r.base_point.x
>> assert r.base_point.y == 15, "wrong y position %d" % r.base_point.y
>>
>> But no output at all
>
> Which output had you expected, and why?
>
>
> --
> André Engels, andreengels at gmail.com
 
Hello, 
 
Oke, I see it now. There is only output when it's not right.
 
Roelof

  		 	   		  


More information about the Tutor mailing list