[issue9574] complex does not parse strings containing decimals
Alexander Belopolsky
report at bugs.python.org
Thu Aug 12 19:18:50 CEST 2010
Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:
Current behavior is also consistent with that of fractions:
>>> Fraction("1/2")
Fraction(1, 2)
>>> Fraction("1 / 2")
Traceback (most recent call last):
..
ValueError: Invalid literal for Fraction: '1 / 2'
I am -1 on this RFE. At most, this can be clarified in the docs.
Allowing whitespace involves too much uncertainly. Would you allow any white space or just chr(0x20)? End-of-line or tab in complex numbers is most likely a typo and should be flagged. What about more exotic unicode whitespace such as chr(0x00A0) or chr(0x2009)? Allow one or any number of whitespace characters?
Users who need a more powerful parser can use eval() or simply remove spaces from their strings before converting them to numbers.
----------
nosy: +belopolsky
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9574>
_______________________________________
More information about the Python-bugs-list
mailing list