4 ms·
Even better, python has named tuples [0]. So if you have a tuple that you are sure will always have the same inputs you can declare it: ``` Point = namedtuple(
by ImageXav 1y ago
Even better, python has named tuples [0]. So if you have a tuple that you are sure will always have the same inputs you can declare it:
```
Point = namedtuple('Point', 'x y')
pt1 = Point(1.0, 5.0)
```
And then call the X or Y coordinates either by index: pt1[0], pt1[1], or coordinate name: pt1.x, pt1.y.
This can be a really handy way to help people understand your code as what you are calling becomes a lot more explicit.
[0] https://stackoverflow.com/questions/2970608/what-are-named-tuples-in-python https://stackoverflow.com/questions/2970608/what-are-named-t...