[New-bugs-announce] [issue42310] for loop creates element in defaultdict

Sandro Barnabishvili report at bugs.python.org
Tue Nov 10 08:39:42 EST 2020


New submission from Sandro Barnabishvili <sandro.barnabishvili at epfl.ch>:

from collections import defaultdict
d = defaultdict(list)
for _ in d['a']: pass
print(d.keys())

For loop creates element with key 'a'. Is it expected behavior?

----------
components: Argument Clinic
messages: 380661
nosy: larry, sandrobarna
priority: normal
severity: normal
status: open
title: for loop creates element in defaultdict
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42310>
_______________________________________


More information about the New-bugs-announce mailing list