Thread-safe way to add a key to a dict only if it isn't already there?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Jul 6 21:36:41 EDT 2018


On Sat, 07 Jul 2018 02:51:41 +0900, INADA Naoki wrote:

> D.setdefault('c', None)

Oh that's clever!

Thanks!



-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson




More information about the Python-list mailing list