How to parse a tuple of "x=y" strings into a dictionary in python?
<p>I have a tuple of strings that I would like to convert into a dictionary by splitting each element using a separator. Is this possible with dictionary comprehension?</p>

<pre><code>&gt;&gt;&gt; x = ('var1=abc', 'var2=xyz', 'var3=10')
&gt;&gt;&gt; y = {k: v for (k, v) in ???}  # this is where I need your help
&gt;&gt;&gt; print y
{ "var1": "abc", "var2": "xyz", "var3": "10" }
</code></pre>

<p>This is as much an learning exercise as anything - so please don't answer with an alternative way of doing it (I have plenty of those) - I want to know if it's possible with a dictionary comprehension.</p>

<p><strong>[UPDATE]</strong></p>

<p>There is a slight modification that I didn't write down first - I need to strip an extraneous linefeed character from the end of each value.</p>

<pre><code>&gt;&gt;&gt; x = ('var1=abc\n', 'var2=xyz\n', 'var3=10')
&gt;&gt;&gt; d = {k: v.strip('\n') for (k, v) in [e.split('=') for e in x]}
&gt;&gt;&gt; d
{'var1': 'abc', 'var3': '10', 'var2': 'xyz'}
</code></pre>

<p>(Of course, now it's not in the same order - but I can live with that. Grrr.)</p>
