This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.snow
Recipients ZackerySpytz, avrahami.ben, eric.snow
Date 2021-06-09.20:42:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1623271363.02.0.424135161394.issue42088@roundup.psfhosted.org>
In-reply-to
Content
> According to the documentation for types.SimpleNamespace, `repr(SimpleNamespace())`
> should return `"SimpleNamespace()"`, but in actuality returns `"namespace()"`.

Note that I purposefully wrote "roughly" in the docs ("The type is roughly equivalent to the following code:").  That code was meant to illustrate the functionality rather than be proscriptive of the implementation.  That said, it certainly would be good for the documentation to match. :)

> but also the (perhaps less interesting issue) of `eval(repr(SimpleNamespace))` resulting in a NameError.

This is true of many of the types exposed by the types module (e.g. types.CodeType).

> I propose that `_PyNamespaceObject`'s __repr__ method be changed to return `"SimpleNamespace(<args>)"`.

My preference would be as outlined in my previous comment: make it a builtin.  However, I'm not in a position to make that happen at the moment.
History
Date User Action Args
2021-06-09 20:42:43eric.snowsetrecipients: + eric.snow, ZackerySpytz, avrahami.ben
2021-06-09 20:42:43eric.snowsetmessageid: <1623271363.02.0.424135161394.issue42088@roundup.psfhosted.org>
2021-06-09 20:42:43eric.snowlinkissue42088 messages
2021-06-09 20:42:42eric.snowcreate