Re: [Python-ideas] namedtuple nit...

2017-07-28 Thread Mike Miller
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 "", line 1, in AttributeError: 'object' object has no attribute '__slots__' >>> object().__dict__ T

Re: [Python-ideas] namedtuple nit...

2017-07-28 Thread Antoine Rozo
> 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 : > > > On 2017-07-27 18:02, Chris Angelico wrote: > > As Ivan said, this is to do with __slot

Re: [Python-ideas] namedtuple nit...

2017-07-28 Thread Mike Miller
That's a subclass. Also: >>> class A(list): __slots__ = () ... >>> >>> a = A() >>> a.foo = 'bar' Traceback (most recent call last): File "", line 1, in 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

Re: [Python-ideas] namedtuple nit...

2017-07-28 Thread Antoine Rozo
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 "", line 1, in AttributeError: 'A' object has no attribute '__dict__' >>> a.append(1) >>> a.append(2) >>

Re: [Python-ideas] namedtuple nit...

2017-07-28 Thread Mike Miller
Nice. Ok, so there are different dimensions of mutability. Still, haven't found any "backdoors" to object(), the one I claimed was immutable. -Mike ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-

Re: [Python-ideas] namedtuple literals [Was: RE a new namedtuple]

2017-07-28 Thread Chris Barker
On Thu, Jul 27, 2017 at 7:42 PM, Ethan Furman wrote: > How I get the point[0] == 3? The first definition of an ntuple had the > order as x, y, and since the proposal is only comparing field names (not > order), this (y, x) ntuple ends up being reversed to how it was specified. > I'm not sure th