In Python 3, most of the time, the result of repr(repr(obj))
will be repr(obj)
wrapped in single quotes. But when obj is a non-empty mapping proxy repr(repr(obj))
is wrapped in double quotes. Why?
This is a Windows 10 server running Python 3.7 on Wing IDE 101.
mappingproxy = type(object.__dict__)
#Single quotes for undefined mapping proxies
print(repr("mappingproxy({})"))
'mappingproxy({})'
#Double quotes for defined mapping proxies
print(repr(repr(object.__dict__)))
<<< "mappingproxy({...})"
#For custom empty mapping proxies...
print(repr(repr(mappingproxy({}))))
<<< 'mappingproxy({})'
#...single, at least for ones evaluating to False
#For mapping proxies evaluating to True...
print(repr(repr(mappingproxy({'a':1, 'b':2}))))
<<< "mappingproxy({'a': 1, 'b': 2})"
#...double
#For non-existant non-empty ones...
print(repr("mappingproxy({'a':1})"))
<<< "mappingproxy({'a':1})"
#...double
#Why is that?
The resultants from the print statements start with "<<<"
.
By the way, I think I can derive an empty mapping proxy representation's representation is wrapped in single quotes.