I don't know exactly how to formulate it, but I want to create a class Point
with which the coordinates of a point can be accessed both as a tuple and individually, as follows:
point.coord
# tuple (x,y)
point.coord.x
point.coord.y
# coordinates x and y
Do I necessarily have to declare a method point.coord()
, or is there such a thing as attributes of attributes? And, for other purposes, what about longer embedded attributes (object.attr1.attr2.attr3
)?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…