Eric Snow <ericsnowcurren...@gmail.com> added the comment:

> 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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42088>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to