A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-February/051389.html below:

[Python-Dev] complex I/O problem

[Python-Dev] complex I/O problemA.M. Kuchling amk at amk.ca
Tue Feb 1 18:16:10 CET 2005
On Tue, Feb 01, 2005 at 11:11:37AM -0500, Neal Becker wrote:
> complex ('(2+2j)')
> Traceback (most recent call last):
>   File "<stdin>", 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.

--amk
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4