On Thu, Jul 20, 2017 at 5:19 AM, Victor Stinner <victor.stin...@gmail.com> wrote:
> For me, namedtuple was first used to upgrade an old API from returning a > tuple to a "named" tuple. There was a hard requirement on backward > compatibility: namedtuple API is a superset of the tuple API. > > For new code, there is no such backward compatibility issue. If you don't > need a type, types.Namespace is a good choice. > > Using ns=types.Namespace, you can replace (x=0, y=1) with ns(x=0, y=1). It > already works, no syntax change. > > *If* someone really wants (x=0, y=1) syntax sugar, I would prefer to get a > namespace (no indexed (tuple) API). > It's a minor point, but the main reason I use namedtuple is because it's far easier to get a hashable object than writing one yourself. Namespaces are not hashable. If the (x=0, y=1) sugar is accepted, IMO it should immutable and hashable like tuples/namedtuples. Best, Lucas
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/