fork download
  1. class Point:
  2. def __init__(self, x, y):
  3. self.x = x
  4. self.y = y
  5. def __str__(self):
  6. return "("+self.x.__str__()+","+self.y.__str__()+")"
  7.  
  8. class LineSegment:
  9. def __init__(self, pt1, pt2):
  10. self.pt1 = pt1
  11. self.pt2 = pt2
  12. def __str__(self):
  13. return "["+self.pt1.__str__()+"],["+self.pt2.__str__()+"]"
  14.  
  15. seg = LineSegment(Point(1, 1), Point(-3, 4))
  16. print(seg)
Success #stdin #stdout 0.02s 5824KB
stdin
Standard input is empty
stdout
[(1,1)],[(-3,4)]