[Python-ideas] namedtuple nit...

Antoine Rozo antoine.rozo at gmail.com
Fri Jul 28 04:06:19 EDT 2017


> If an object has no slots or dict and does not accept attribute
assignment, is it not effectively immutable?

No, not necessarily.

class A(list): __slots__ = ()

2017-07-28 10:00 GMT+02:00 Mike Miller <python-ideas at mgmiller.net>:

>
>
> On 2017-07-27 18:02, Chris Angelico wrote:
> > As Ivan said, this is to do with __slots__. It's nothing to do with
> > immutability:
>
> >>> object().__slots__
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> AttributeError: 'object' object has no attribute '__slots__'
>
> >>> object().__dict__
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> AttributeError: 'object' object has no attribute '__dict__'
> >>>
>
> If an object has no slots or dict and does not accept attribute
> assignment, is it not effectively immutable?
>
> -Mike
>
> _______________________________________________
> 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/
>



-- 
Antoine Rozo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170728/edde1cf9/attachment.html>


More information about the Python-ideas mailing list