Any good use for list/dict assignment during for loop?
<p>I saw some code yesterday in <a href="http://stackoverflow.com/q/9372824/505154">this question</a> that I had not seen before, this line in particular:</p>

<pre><code>for xyz[num] in possible[num]:
    ...
</code></pre>

<p>So as this loop runs, the elements from <code>possible[num]</code> are assigned to the list <code>xyz</code> at position <code>num</code>.  I was really confused by this so I did some tests, and here is some equivalent code that is a little more explicit:</p>

<pre><code>for value in possible[num]:
    xyz[num] = value
    ...
</code></pre>

<p>I definitely intend to always use this second format because I find the first more confusing than it is worth, but I was curious... so:</p>

<p><strong>Is there any good reason to use this "feature", and if not, why is it allowed?</strong></p>

<p>Here are a couple of stupid use cases I came up with (stupid because there are much better ways to do the same thing), the first is for rotating the letters of the alphabet by 13 positions, and the second is for creating a dictionary that maps characters from rot13 to the character 13 positions away.</p>

<pre><code>&gt;&gt;&gt; import string
&gt;&gt;&gt; rot13 = [None]*26
&gt;&gt;&gt; for i, rot13[i%26] in enumerate(string.ascii_lowercase, 13): pass
...
&gt;&gt;&gt; ''.join(rot13)
'nopqrstuvwxyzabcdefghijklm'

&gt;&gt;&gt; rot13_dict = {}
&gt;&gt;&gt; for k, rot13_dict[k] in zip(rot13, string.ascii_lowercase): pass
...
&gt;&gt;&gt; print json.dumps(rot13_dict, sort_keys=True)
{"a": "n", "b": "o", "c": "p", "d": "q", "e": "r", "f": "s", "g": "t", "h": "u", "i": "v", "j": "w", "k": "x", "l": "y", "m": "z", "n": "a", "o": "b", "p": "c", "q": "d", "r": "e", "s": "f", "t": "g", "u": "h", "v": "i", "w": "j", "x": "k", "y": "l", "z": "m"}
</code></pre>
