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>There's a more concise way, but it's not really any cleaner and it's certainly not clearer.</p>

<pre><code>x = complex(*[float(w) for w in '1.000,.001'.split(',')])
</code></pre>

python complex-numbers