[Python-ideas] A namedtuple literal.

Haoyi Li haoyi.sg at gmail.com
Wed Apr 2 06:59:40 CEST 2014


I personally made my own "namedtuple" "literal"

class Container:
    pass

def t(**kw):
    c = Container()
    for k, w in kw.items():
        setattr(c, k, w)
    return c

t(color=c, position=p)


On Tue, Apr 1, 2014 at 9:55 PM, Eric Snow <ericsnowcurrently at gmail.com>wrote:

> On Tue, Apr 1, 2014 at 10:40 PM, Eric Snow <ericsnowcurrently at gmail.com>
> wrote:
> > (Inspired by
> https://mail.python.org/pipermail/python-ideas/2010-October/008532.html)
> >
> > (color: c, position: p)
> >
> > This would automatically created a namedtuple class and provide an
> > instance of it.
>
> Ooh.  How about an OrderedDict literal:
>
> ['a' : 1, 'b' : 2, 'c' : 3]
>
> (courtesy of
> https://mail.python.org/pipermail/python-ideas/2010-October/008484.html)
>
> reading-too-many-archived-threads-ly,
>
> -eric
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140401/351bd8a4/attachment.html>


More information about the Python-ideas mailing list