[Python-ideas] namedtuple literals [Was: RE a new namedtuple]
markusmeskanen at gmail.com
Sun Jul 23 14:36:30 EDT 2017
23.7.2017 20.59 "Michel Desmoulin" <desmoulinmichel at gmail.com> wrote:
I'm not sure why everybody have such a grip on the type.
When we use regular tuples, noone care, it's all tuples, no matter what.
Well in that case, let's make all those namedtuple and be done with it.
If somebody really needs a type, this person will either used
collections.namedtuple the old way, or use a namespace or a class.
If using the type "namedtuple" is an issue because it already exist,
let's find a name for this new type that convey the meaning, like
labelledtuple or something.
The whole point of this is to make it a litteral, simple and quick to
use. If you make it more than it is, we already got everything to do
this and don't need to modify the language.
+1 to this, why not just have: type((x=0, y=0)) == namedtuple similar to
how tuples work. If you want to go advanced, feel free to use classes.
Also, would it be crazy to suggest mixing tuples and named tuples:
>>> t = ('a', x='b', y='c', 'd')
>>> t, t
Just an idea, I'm not sure if it would have any use though.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas