want a calculation result instead of <bound method ...Python 2.8 -
want a calculation result instead of <bound method ...Python 2.8 -
i have tried finding in docs don't quite it. starting work classes, when seek result, instead of actual 'width' maybe need get not sure.. sounds complicated result. can advise?
i have:
class rectangle(object): def __init__(self, pt_ll, pt_ur): self.ll = pt_ll self.lr = point(pt_ur.x, pt_ll.y) self.ur = pt_ur self.ul = point(pt_ll.x, pt_ur.y) def width(self): """returns width-float of rectangle.""" w = self.ur.x - self.ll.x homecoming w
then phone call it:
r = rectangle(point(0,0), point(10,10)) print r.ur.x print r.ll.x print r.width
and output:
10.0 0.0 <bound method rectangle.width of <__main__.rectangle object @ 0x000000000b5cbc50>>
print r.width
this returns width method itself, see in output. want phone call method need instead this:
print r.width()
this hints @ interesting thing python, can pass around functions can other variables.
methods
Comments
Post a Comment