You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/serhiy-storchaka'closed_at=<Date2015-03-24.17:33:09.654>created_at=<Date2015-02-23.19:21:48.535>labels= ['type-feature', 'library']
title='pprint: added support for mapping proxy'updated_at=<Date2015-03-24.17:33:09.653>user='https://github.com/serhiy-storchaka'
Mapping proxy is quite often used in building . For example types __dict__ are mapping proxy.
>>> bool.__dict__
mappingproxy({'__or__': <slot wrapper '__or__' of 'bool' objects>, '__doc__': 'bool(x) -> bool\n\nReturns True when the argument x is true, False otherwise.\nThe builtins True and False are the only two instances of the class bool.\nThe class bool is a subclass of the class int, and cannot be subclassed.', '__xor__': <slot wrapper '__xor__' of 'bool' objects>, '__and__': <slot wrapper '__and__' of 'bool' objects>, '__rxor__': <slot wrapper '__rxor__' of 'bool' objects>, '__repr__': <slot wrapper '__repr__' of 'bool' objects>, '__new__': <built-in method __new__ of type object at 0x82a1140>, '__rand__': <slot wrapper '__rand__' of 'bool' objects>, '__str__': <slot wrapper '__str__' of 'bool' objects>, '__ror__': <slot wrapper '__ror__' of 'bool' objects>})
Mapping proxy is not a subclass of dict, so pprint doesn't print it pretty. Proposed patch adds support for mapping proxies in pprint.
>>> from pprint import pprint as pp
>>> pp(bool.__dict__)
mappingproxy({'__and__': <slot wrapper '__and__' of 'bool' objects>,
'__doc__': 'bool(x) -> bool\n'
'\n'
'Returns True when the argument x is true, False '
'otherwise.\n'
'The builtins True and False are the only two '
'instances of the class bool.\n'
'The class bool is a subclass of the class int, and '
'cannot be subclassed.',
'__new__': <built-in method __new__ of type object at 0x82a1140>,
'__or__': <slot wrapper '__or__' of 'bool' objects>,
'__rand__': <slot wrapper '__rand__' of 'bool' objects>,
'__repr__': <slot wrapper '__repr__' of 'bool' objects>,
'__ror__': <slot wrapper '__ror__' of 'bool' objects>,
'__rxor__': <slot wrapper '__rxor__' of 'bool' objects>,
'__str__': <slot wrapper '__str__' of 'bool' objects>,
'__xor__': <slot wrapper '__xor__' of 'bool' objects>})
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: