Here's an example you might want to consider:

    >>> from collections import namedtuple

    >>> Point = namedtuple('Point', ['x', 'y'])
    >>> Point(1, 2)
    Point(x=1, y=2)
    >>> Point(1, 2) == (1, 2)
    True

    >>> Polar = namedtuple('Polar', ['r', 'theta'])
    >>> Polar(1, 2)
    Polar(r=1, theta=2)
    >>> Polar(1, 2) == (1, 2)
    True

    >>> Point(1, 2) == Polar(1, 2)
    True
    >>> hash(Point(1, 2)) == hash(Polar(1, 2)) == hash((1, 2))
   True

-- 
Jonathan
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/Z5QX4YD7AL7WZXNUWTTRZIOHCLBJMPAT/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to