x[i] as loop variable
Alex Martelli
aleax at aleax.it
Mon Oct 27 09:07:14 EST 2003
Raymond Hettinger wrote:
> But that doesn't mean going off the deep-end and writing:
>
> for a[3] in data: . . .
> for a[:] in data: . . .
> for a.abomination in data: . . .
> for d[k] in data: . . .
Still, there IS some "coolness factor" in:
>>> d = {}
>>> for k, d[k] in pairs: pass
...
>>> d
{'p': 'i', 'k': 'o', 'b': 'a', 'm': 'a', 'l': 'u'}
after all, "for k, d[k] in pairs: pass" is so much more
show-offy than a mere "d.update(dict(pairs))"...!-)
Alex
More information about the Python-list
mailing list