[Python-ideas] namedtuple nit...

Mike Miller python-ideas at mgmiller.net
Fri Jul 28 04:00:13 EDT 2017



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


More information about the Python-ideas mailing list