[Tutor] pure function problem

Dave Angel davea at ieee.org
Fri Sep 24 12:29:03 CEST 2010

  On 2:59 PM, Roelof Wobben wrote:
> ----------------------------------------
>> From: steve at pearwood.info
>> <snip>
>> 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?
>> <snip>
> 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.


More information about the Tutor mailing list