[Tutor] pure function problem

Roelof Wobben rwobben at hotmail.com
Fri Sep 24 07:43:42 CEST 2010




----------------------------------------
> From: steve at pearwood.info
> To: tutor at python.org
> Date: Fri, 24 Sep 2010 13:00:40 +1000
> Subject: Re: [Tutor] pure function problem
>
> Roelof, please learn to delete unnecessarily quoted text. There's no
> need to quoted the entire discussion every time you answer.
>
> On Fri, 24 Sep 2010 06:20:25 am Roelof Wobben wrote:
>
>> time = tijd()
> [...]
>> print time(uitkomst)
>
> Why are you calling time as a function, when it is a tijd instance?
>
>
>
>
> --
> Steven D'Aprano
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
 
 
Hello Steve,
 
I found this in my tutorial.
 
13.8. Instances as return values¶
Functions can return instances. For example, find_center takes a Rectangle as an argument and returns a Point that contains the coordinates of the center of the Rectangle:
def find_center(box):
    p = Point()
    p.x = box.corner.x + box.width/2.0
    p.y = box.corner.y - box.height/2.0
    return p
To call this function, pass box as an argument and assign the result to a variable:
>>> center = find_center(box)
>>> print_point(center)
(50.0, 100.0)

 
So i followed it but appearently not the good way.
 
Roelof
  		 	   		  


More information about the Tutor mailing list