[Python-Dev] complex I/O problem (original) (raw)
Josiah Carlson jcarlson at uci.edu
Tue Feb 1 18:31:22 CET 2005
- Previous message: [Python-Dev] complex I/O problem
- Next message: Moving towards Python 3.0 (was Re: [Python-Dev] Speed up functioncalls)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"A.M. Kuchling" <amk at amk.ca> wrote:
On Tue, Feb 01, 2005 at 11:11:37AM -0500, Neal Becker wrote: > complex ('(2+2j)') > Traceback (most recent call last): > File "", line 1, in ? > ValueError: complex() arg is a malformed string > > Whatever format is used for output should be accepted as input! This isn't true in general; it's not true of strings, for example, nor of files. Parsing complex numbers would be pretty complicated, because it would have to accept '(2+2j)', '2+2j', '3e-6j', and perhaps even '4j+3'. It seems easier to just use eval() than to make complex() implement an entire mini-parser.
Which brings up the fact that while some things are able to make the eval(str(obj)) loop, more are able to make the eval(repr(obj)) loop (like strings themselves...).
- Josiah
- Previous message: [Python-Dev] complex I/O problem
- Next message: Moving towards Python 3.0 (was Re: [Python-Dev] Speed up functioncalls)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]