Yes, but A objects have no slots, no dict, do not accept attribute assignment, but are mutable.
>>> a = A() >>> a [] >>> a.__slots__ () >>> a.__dict__ Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'A' object has no attribute '__dict__' >>> a.append(1) >>> a.append(2) >>> a [1, 2] 2017-07-28 20:23 GMT+02:00 Mike Miller <python-id...@mgmiller.net>: > That's a subclass. Also: > > >>> class A(list): __slots__ = () > ... > >>> > >>> a = A() > >>> a.foo = 'bar' > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > AttributeError: 'A' object has no attribute 'foo' > > -Mike > > > On 2017-07-28 01:06, Antoine Rozo wrote: > >> > 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__ = () >> >> _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Antoine Rozo
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/