How to define basic Python structures?
问题 I'm coming to Python from Racket. In Racket, I would define a Point structure like this: (struct Point (x y) #:transparent) A point is now a structure with two fields named x and y . I can compare two structures for (deep) equality by calling equal? . What is the equivalent in Python? It looks to me like I have to write twelve lines: class Point(): def __init__(self,x,y): self.x = x; self.y = y; def __eq__(self, other): return ((type(other) is Point) and self.x == other.x and self.y == other