How to convert the string '1.000,0.001' to the complex number (1+0.001j)?
<p>The best I could come up with is</p>

<pre><code>s = '1.000,0.001'
z = [float(w) for w in s.split(',')]
x = complex(z[0],z[1])
</code></pre>

<p>Is there a shorter, cleaner, nicer way?</p>

<p>If you can trust the data to not be dangerous or want this for code golf:</p>

<pre><code>&gt;&gt;&gt; eval('complex(%s)' % s)
(1+0.001j)
</code></pre>

python complex-numbers