Steven D'Aprano wrote:
> Do nothing?
> I don't have to suggest a better idea, since its not me proposing a
> change. I don't think any change is needed. It is up to you to firstly
> justify that a change is needed, and only then justify a specific
> response to that need.
[snip]
> If you persona
On Thu, Apr 16, 2020 at 01:11:46PM -0300, Soni L. wrote:
> we can't break setdefault (particularly for tuple keys), do you have a
> better idea?
Do nothing?
I don't have to suggest a better idea, since its not me proposing a
change. I don't think any change is needed. It is up to you to firstl
On 2020-04-16 2:42 p.m., Andrew Barnert wrote:
On Apr 16, 2020, at 07:19, Soni L. wrote:
what about a dict.setdefaults (note the s) that takes in an
iterable or a dict, and uses insert-or-ignore behaviour?
(unfortunately a lot of iterables and all generators are hashable,
and we can't b
On Apr 16, 2020, at 07:19, Soni L. wrote:
>
> what about a dict.setdefaults (note the s) that takes in an iterable or a
> dict, and uses insert-or-ignore behaviour? (unfortunately a lot of iterables
> and all generators are hashable, and we can't break that.)
>
> I could really use something
On 2020-04-16 11:43 a.m., Steven D'Aprano wrote:
On Thu, Apr 16, 2020 at 11:17:33AM -0300, Soni L. wrote:
> what about a dict.setdefaults (note the s)
Do you have any idea of how much confusion and many silent errors will
be caused by having methods setdefault and setdefaults on the same
cl
On Thu, Apr 16, 2020 at 11:17:33AM -0300, Soni L. wrote:
> what about a dict.setdefaults (note the s)
Do you have any idea of how much confusion and many silent errors will
be caused by having methods setdefault and setdefaults on the same
class?
--
Steven
__
what about a dict.setdefaults (note the s) that takes in an iterable or
a dict, and uses insert-or-ignore behaviour? (unfortunately a lot of
iterables and all generators are hashable, and we can't break that.)
I could really use something like that tbh.
On 2020-04-16 9:47 a.m., Alex Hall wrote
I just tried playing with this idea:
from collections import UserDict
class InsertOrIgnoreDict(UserDict):
__setitem__ = UserDict.setdefault
print(InsertOrIgnoreDict([(1, 2), (3, 4)]))
It caused an infinite chain of exceptions:
Traceback (most recent call last):
File
"/home/alex/.pyenv/