"Christophe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] <snip> > Oups, I was too fast to read what was written. I though you only changed > one of the terms ( str -> repr ). > > You'll note that repr and str produce the exact same result for complex. > And also, I'm not sure using eval anywhere is a good idea so it probably > doesn't help for what the OP wants to do.
An eval-less approach - the problem is the enclosing parens. >>> a = 1+3j >>> str(a) '(1+3j)' >>> complex(str(a)) Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: complex() arg is a malformed string >>> complex(str(a)[1:-1]) (1+3j) >>> complex(str(a).strip("()")) (1+3j) -- Paul -- http://mail.python.org/mailman/listinfo/python-list