-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Closed
Labels
easystdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
Proposal:
The pprint code has a number of type or protocol specific handlers but doesn't have one for frozendict yet. So, we don't currently get pretty printing for frozendict:
>>> f = frozendict.fromkeys(range(10))
>>> g = frozendict.fromkeys(range(10))
>>> h = {0: f, 1: frozendict({2: g})}
>>> pprint.pp(h)
{0: frozendict({0: None, 1: None, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None}),
1: frozendict({2: frozendict({0: None, 1: None, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None})})}We want frozendict to be pretty printed like this:
>>> f = frozendict.fromkeys(range(10))
>>> g = frozendict.fromkeys(range(10))
>>> h = {0: f, 1: frozendict({2: g})}
>>> pprint.pp(h)
{0: frozendict({0: None,
1: None,
2: None,
3: None,
4: None,
5: None,
6: None,
7: None,
8: None,
9: None}),
1: frozendict({2: frozendict({0: None,
1: None,
2: None,
3: None,
4: None,
5: None,
6: None,
7: None,
8: None,
9: None})})}Let me know whether you think the pretty printing should be different.
cc: @rhettinger for validating that the pretty printing should be as above.
I'll create a trivial PR to fix this once validated.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
easystdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement