Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make __repr__ more similar to other mapping types #58

Merged
merged 2 commits into from
Feb 9, 2021

Conversation

ofek
Copy link
Contributor

@ofek ofek commented Feb 8, 2021

Resolves #17

Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from collections import ChainMap, OrderedDict, defaultdict
>>>
>>> d = {'one': 1, 'two': 2}
>>> d
{'one': 1, 'two': 2}
>>> ChainMap({'one': 1}, {'two': 2})
ChainMap({'one': 1}, {'two': 2})
>>> OrderedDict((('one', 1), ('two', 2)))
OrderedDict([('one', 1), ('two', 2)])
>>> dd = defaultdict(int)
>>> dd.update(d)
>>> dd
defaultdict(<class 'int'>, {'one': 1, 'two': 2})

@ofek
Copy link
Contributor Author

ofek commented Feb 8, 2021

cc @1st1 😄

@1st1
Copy link
Member

1st1 commented Feb 8, 2021

Hm, I'm not sure I like this change. The immutables. prefix gives the user an immediate idea of what particular Map they're looking at, which is super important when you're debugging things.

@ofek
Copy link
Contributor Author

ofek commented Feb 8, 2021

@1st1 Addressed!

@1st1
Copy link
Member

1st1 commented Feb 8, 2021

@elprans Do you like this proposal? I know that you like to see object IDs in repr. Would this make your debug experience worse?

@elprans
Copy link
Member

elprans commented Feb 9, 2021

Since the content is included in the repr, the id is less important, so I'm fine with this.

@fantix fantix merged commit 8af1502 into MagicStack:master Feb 9, 2021
@ofek ofek deleted the pretty-repr branch February 9, 2021 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

immutables.Map.__str__ doesn't match dict.__str__
4 participants