Python 3 name tuple position
Question: If I have the coordinate tuple `(10.1, 15.2)`, how can I make it so that I can
call `10.1` as simply `x` instead of `coordinates[0]`, and `y` instead of
`coordinates[1]`?

I want to do this so that I can pass a tuple from function to function while
still being able to call `x` and `y` easily. I could just:

    
    
    x = coordinates[0]
    y = coordinated[1]
    

but that seems like a bad idea -- lengthy and I'd have to repeat it for each
function.


Answer: Use
[namedtuple](https://docs.python.org/3.4/library/collections.html#collections.namedtuple):

    
    
       > from collections import namedtuple
       > c = namedtuple('Coords',['x','y'])
       > xy = c(5,6)
       > xy
       => Coords(x=5, y=6)
       > xy.x
       => 5
       > xy.y
       => 6
    

