Visitar URL original
attrs be dictionary?? by busterbeam · Pull Request #28078 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20250819002259/https://github.com/python/cpython/pull/28078
Skip to content

attrs be dictionary?? #28078

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

Closed
wants to merge 1 commit into from
Closed

attrs be dictionary?? #28078

wants to merge 1 commit into from

Conversation

busterbeam
Copy link

Just a suggestion but every time I use this Parser I'm always making the tupled list into the dictionary. Dictionary makes more sense for attribute property nature of html(/xml) nature of tags

Just a suggestion but every time I use this Parser I'm always making the tupled list into the dictionary.  Dictionary makes more sense for attribute property nature of html(/xml) nature of tags
@remilapeyre
Copy link
Contributor

Hi @busterbeam, thanks for looking into ways to improve Python but this is a breaking change so it would first need to be discussed on the python-ideas mailing list and a deprecation period would be needed. In practice I think that there is not much probability that such a change will be merged as it would break all existing code using parser with a very limited upside as attrs = dict(attrs) is not that much code.

@busterbeam
Copy link
Author

Well who was the idiot who set it up like this in the first place??

@remilapeyre
Copy link
Contributor

It has been like this for as long as 26 years. It has nothing idiotic, attributes in XML can appear multiple times and are ordered, dictionnaries in Python can not have multiple time the same key and are only ordered since Python 3.6, they were not in Python 1.3.

Please refrain from insulting peoples when contributing, Python is made by a large group of volunteers and there is really no reason to insult any of them.

@ambv
Copy link
Contributor

ambv commented Sep 3, 2021

It can't be a simple dict[str, str]. It could have maybe been a dict[str, list[str]] (as done by urllib.parse.parse_qs) or a multidict (but AFAICT we don't have one in the stdlib) for the reasons @remilapeyre points out.

@ambv ambv closed this Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants