Why are arbitrary target expressions allowed in for-loops? – stackoverflow.com

I accidentally wrote some code like this: foo = [42] k = {'c': 'd'} for k['z'] in foo: # Huh?? print k But to my surprise, this was not a syntax error. Instead, it prints {'c': 'd', 'z': 42}. ...

from Hot Questions - Stack Exchange OnStackOverflow
via Blogspot

Share this

0 Comment to "Why are arbitrary target expressions allowed in for-loops? – stackoverflow.com"