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 <>
> 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.
Date User Action Args
2021-06-09 20:42:43eric.snowsetrecipients: + eric.snow, ZackerySpytz, avrahami.ben
2021-06-09 20:42:43eric.snowsetmessageid: <>
2021-06-09 20:42:43eric.snowlinkissue42088 messages
2021-06-09 20:42:42eric.snowcreate