On 07/06/2018 10:51 AM, INADA Naoki wrote: > On Sat, Jul 7, 2018 at 2:49 AM Steven D'Aprano wrote:
>> I have a dict with string keys: >> >> --> D = {'a': None, 'b': None} >> How do I do a thread-safe insertion if, and only if, the key isn't >> already there? >
D.setdefault('c', None)
This is how Enum avoids race conditions when setting up the re.RegexType enumeration. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list