[Tutor] pure function problem

Roelof Wobben rwobben at hotmail.com
Fri Sep 24 12:40:46 CEST 2010




----------------------------------------
> Date: Fri, 24 Sep 2010 06:29:03 -0400
> From: davea at ieee.org
> To: rwobben at hotmail.com
> CC: tutor at python.org
> Subject: Re: [Tutor] pure function problem
>
> On 2:59 PM, Roelof Wobben wrote:
>>
>>
>> ----------------------------------------
>>> From: steve at pearwood.info
>>> 
>>> On Fri, 24 Sep 2010 06:20:25 am Roelof Wobben wrote:
>>>
>>>> time =ijd()
>>> [...]
>>>> print time(uitkomst)
>>> Why are you calling time as a function, when it is a tijd instance?
>>>
>>> 
>>
>> 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 =oint()
>> p.x =ox.corner.x + box.width/2.0
>> p.y =ox.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 =ind_center(box)
>>>>> print_point(center)
>> (50.0, 100.0)
>>
>>
>> So i followed it but appearently not the good way.
>>
>> Roelof
> There's a big difference between print_point() and print time().
>
> print_point() in your tutorial is a function, presumably defined
> someplace else.
>
> You used print time(), (no underscore), which uses the print statement,
> and tries to call a function called time().
>
> Since you defined time as an instance of your class, and didn't do
> anything special, it's not callable.
>
> DaveA
>
 
Oke, 
 
I see it now.
I have to us a function that i had to write a few questions before.
 
Thanks everybody 

Roelof

  		 	   		  


More information about the Tutor mailing list