#18315 closed Cleanup/optimization (fixed)
Document QueryDict.pop & popitem
Reported by: | gcbirzan | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
All the 'regular' operations on QueryDict return a single value, with a 'list' variant for returning a list of items. pop() pops a list, popitem() for just one item. This is not only inconsistent, but also not documented.
I'd prefer a solution that makes pop return a single item, vs mentioning it in the docs, but that breaks backwards compatibility.
Change History (10)
comment:1 by , 13 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 12 years ago
This confused me to no end before I found out that doing QueryDictkey would not return the same value as QueryDict.pop('key'). This hardly seems like it conform with other uses of pop.
comment:3 by , 12 years ago
Given a QueryDict d={'k':['a', 'b'], 'v':['1', '2']} then d.get('k')='a', but d.pop('k')=['a', 'b']
I've been using pop() to get me the list of values. Changing the functionality would be a backwards compatibility problem, indeed. I recommend to update the documentation instead.
comment:4 by , 12 years ago
Type: | Uncategorized → Cleanup/optimization |
---|
comment:6 by , 11 years ago
Component: | HTTP handling → Documentation |
---|---|
Easy pickings: | set |
Summary: | QueryDict.pop is inconsistent → Document QueryDict.pop & popitem |
comment:7 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I'm not convinced this is a sufficient reason to break backwards compatibility.