Skip to main content
added 317 characters in body
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158

Actually, having read a del test, now it makes perfect sense to me. Partly this is due to the documentation's focus on manipulating protocol headers, so del headers["Received"] leads to a different intuition.

To "shorten" an entry we would need to go outside what the OP code offers convenient access to. Though such mutation leaves _count in the wrong state.

>>> d
MultiDict({'a': [1, 2]})
>>> vals = d['a']
>>> del vals[-1]
>>> d['a']
[1]

Actually, having read a del test, now it makes perfect sense to me. Partly this is due to the documentation's focus on manipulating protocol headers, so del headers["Received"] leads to a different intuition.

To "shorten" an entry we would need to go outside what the OP code offers convenient access to. Though such mutation leaves _count in the wrong state.

>>> d
MultiDict({'a': [1, 2]})
>>> vals = d['a']
>>> del vals[-1]
>>> d['a']
[1]
added 1 character in body
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158

motivating example

The supplied test suite, while instructive, alas is very generic.

It would be helpful to show how, IDK, a Flask app, or some other Use Case, can solve a business problem using this library more simply than it could with a competing technique. (defaultdict(list) springs to mind.)

motivating example

The supplied test suite, while instructive, alas is very generic.

It would be helpful to show how, IDK, a Flask app, or some other Use Case, can solve a business problem using this library more simply than it could with a competing technique. (defaultdict(list) springs to mind.)

added 1 character in body
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158

I similarly found this confusing / unintuitive. Apparently insert & delete are not symmetric with each another. You had a different concept of what a MultiDict looks like than I did, partly due to a comparison I drew with a MultiSet. Writing some English sentences of documentation would help to align an app engineersengineer's thinking with your own.

I thought the first del would delete the \$2\$ element and decrement count from \$2 \rightarrow 1\$, second del sends count from \$1 \rightarrow 0\$, and only an attempted third del would be invalid app-level code. But now I see you had a different concept in mind, OK.

I similarly found this confusing / unintuitive. You had a different concept of what a MultiDict looks like than I did, partly due to a comparison I drew with a MultiSet. Writing some English sentences of documentation would help to align an app engineers thinking with your own.

I thought the first del would decrement count from \$2 \rightarrow 1\$, second del from \$1 \rightarrow 0\$, and only an attempted third del would be invalid app-level code. But now I see you had a different concept in mind, OK.

I similarly found this confusing / unintuitive. Apparently insert & delete are not symmetric with each another. You had a different concept of what a MultiDict looks like than I did, partly due to a comparison I drew with a MultiSet. Writing some English sentences of documentation would help to align an app engineer's thinking with your own.

I thought the first del would delete the \$2\$ element and decrement count from \$2 \rightarrow 1\$, second del sends count from \$1 \rightarrow 0\$, and only an attempted third del would be invalid app-level code. But now I see you had a different concept in mind, OK.

Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158
Loading