[Python-ideas] Adding "+" and "+=" operators to dict
MRAB
python at mrabarnett.plus.com
Thu Feb 12 19:55:23 CET 2015
On 2015-02-12 16:27, Chris Angelico wrote:
> On Fri, Feb 13, 2015 at 3:21 AM, Steven D'Aprano <steve at pearwood.info> wrote:
>> On Fri, Feb 13, 2015 at 02:46:45AM +1100, Chris Angelico wrote:
>>
>>> Imagine if two people independently build shopping lists
>>
>> Sorry, was that shopping *lists* or shopping *dicts*?
>
> I've never heard anyone in the real world talk about "shopping dicts"
> or "shopping arrays" or "shopping collections.Sequences". It's always
> "shopping lists". The fact that I might choose to represent one with a
> dict is beside the point. :)
>
>>> - "this is the stuff we need" - and
>>> then combine them.
>>
>> Why would you discard duplicates? If you need 2 loaves of bread, and I
>> need 1 loaf of bread, and the merged shopping list has anything less
>> than 3 loaves of bread, one of us is going to miss out.
>>
>
> I live in a house with a lot of people. When I was younger, Mum used
> to do most of the shopping, and she'd keep an eye on the fridge and
> usually know what needed to be replenished; but some things she didn't
> monitor, and relied on someone else to check them. If there's some
> overlap in who checks what, we're all going to notice the same need -
> we don't have separate requirements here. One person notes that we're
> down to our last few eggs and should buy another dozen; another person
> also notes that we're down to our last few eggs, but thinks we should
> probably get two dozen. Getting *three* dozen is definitely wrong
> here. And definitely her views on how much we should buy would trump
> my own, as my experience was fairly minimal.
>
What if X wants a pizza and Y wants a pizza? If you get only one,
someone is going to be unhappy!
> (These days, most of us are adult, and matters are a bit more
> complicated. So I'm recalling "the simpler days of my youth" for the
> example.)
>
More information about the Python-ideas
mailing list