15.4 인스턴스를 반환값으로 하기
함수는 인스턴스를 반환할 수 있다. 예를 들어 find_center는 Rectangle을 인수로 받아서 Rectangle의 중심 좌표를 담은 Point를 반환할 수 있다.
def find_center(rect):
p = Point()
p.x = rect.corner.x + rect.width/2
p.y = rect.corner.y + rect.height/2
return p
다음은 box를 인수로 전달하고, 결과 Point를 center에 할당한다.
>>> center = find_center(box)
>>> print_point(center)
(50, 100)