of wrote: > a = 1+3j > complex(str(a)) > > Why does this not work ? It should
It would be nice. Looks like str(1+3j) is returning an expression in string form. Maybe there is no actual complex literal. eval (str(1+3j)) works. Python 2.4.2 (#1, Jan 23 2006, 21:24:54) [GCC 3.3.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 1+3j (1+3j) >>> str(1+3j) '(1+3j)' >>> complex (str(1+3j)) Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: complex() arg is a malformed string >>> eval (str(1+3j)) (1+3j) >>> eval(str(1+3j))**2 (-8+6j) -- http://mail.python.org/mailman/listinfo/python-list