How can I understan the "for" here?
Kermit Mei
kermit.mei at gmail.com
Thu Dec 11 09:44:20 EST 2008
Hello all, look at the following sentence:
>>>params = {"server":"mpilgrim", "database":"master", "uid":"sa",
"pwd":"secret"}
>>> ["%s=%s" % (k, v) for k, v in params.items()]
['pwd=secret', 'database=master', 'uid=sa', 'server=mpilgrim']
I can't understand the second sentence because of the "for ... in".
I consider that the syntactics of "for" should be:
for k,v in params.items():
......
But there's no a colon here, why it can work?
Thanks!
More information about the Python-list
mailing list