[Python-ideas] recorarray: a mutable alternative to namedtuple

Zaur Shibzukhov szport at gmail.com
Thu Mar 26 06:17:48 CET 2015



вторник, 17 марта 2015 г., 19:52:28 UTC+3 пользователь Luciano Ramalho 
написал:
>
> Sometimes we need a simple class to hold some mutable attributes, 
> provide a nice repr, support == for testing, and support iterable 
> unpacking, so you can write: 
>
> >>> p = Point(3, 4) 
> >>> x, y = p 
>
> That's very much like the classes built by namedtuple, but mutable. 
>
> I propose we add to the collections module another class factory. I am 
> calling it plainclass, but perhaps we can think of a better name. Here 
> is how it would be used: 
>
> >>> import collections 
> >>> Point = collections.plainclass('Point', 'x y') 
>
> The signature of the plainclass function would be exactly the same as 
> namedtuple, supporting the same alternative ways of naming the 
> attributes. 
>
>
There is an attempt to make such alternative: recordarray 
<https://pypi.python.org/pypi/recordarray>.
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150325/98edc8fe/attachment-0001.html>


More information about the Python-ideas mailing list