C
ckrieg
Just a quick question. Consider this:
dict01 = { '1': 'a', '2': 'b' }
for c in range(1, 3):
print "%(c)s" % locals(), "%(1)s" % dict01
Returns:
1 a
2 a
But, using this loop instead:
for c in range(1, 3):
print "%(c)s %(1)s" % (locals(), dict01)
Results in an error: TypeError: format requires a mapping
Why doesn't the second loop work? It seems to be a cleaner way of
doing this. Am I missing something?
dict01 = { '1': 'a', '2': 'b' }
for c in range(1, 3):
print "%(c)s" % locals(), "%(1)s" % dict01
Returns:
1 a
2 a
But, using this loop instead:
for c in range(1, 3):
print "%(c)s %(1)s" % (locals(), dict01)
Results in an error: TypeError: format requires a mapping
Why doesn't the second loop work? It seems to be a cleaner way of
doing this. Am I missing something?