On Wed, Apr 11, 2018 at 5:08 AM, Steven D'Aprano <st...@pearwood.info>
wrote:

> On Wed, Apr 11, 2018 at 08:21:01AM -0300, Joao S. O. Bueno wrote:
> > I just came across a code snippet that
> > would define a method with the "__dict__" name  - like in:
> >
> > class A:
> >     def __dict__(self):
> >          return ()
>
> That's a strange thing to do, but I don't think it ought to be illegal.
> Consenting adults and all that.


Python's guarantee in this case goes no further than that it promises not
to crash in C code. There's a rule in the language reference that says that
all __dunder__ names are reserved for the implementation and they should
only be used according to the documentation. So, indeed, it's not illegal,
but you are not guaranteed that anything works, either.

-- 
--Guido van Rossum (python.org/~guido)
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to