A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2018-April/152693.html below:

[Python-Dev] Possible undefined behavior on creating a method named "__dict__"

[Python-Dev] Possible undefined behavior on creating a method named "__dict__"Guido van Rossum guido at python.org
Wed Apr 11 20:25:30 EDT 2018
On Wed, Apr 11, 2018 at 5:08 AM, Steven D'Aprano <steve at 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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180411/2cda0c78/attachment.html>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4