This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients ezio.melotti, mark.dickinson, rhettinger, serhiy.storchaka, terry.reedy, vstinner, weightwatchers-carlanderson
Date 2021-03-20.14:41:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616251287.8.0.603906849027.issue43520@roundup.psfhosted.org>
In-reply-to
Content
Usually, constructors try to accept format returned by repr(obj), or even str(obj). It's the case for Fraction:

>>> str(fractions.Fraction(1, 2))
'1/2'
>>> fractions.Fraction("1/2")
Fraction(1, 2)

It works as expected.

I dislike the idea of trying to handle more Unicode characters which "look like" "/", or characters like "⅔". It sounds like a can of worm, and I don't think that such feature belongs to the stdlib. You can easily write your helper function accepting string and returning a fraction.

If someone is motivated to accept more character, I would prefer to have an unified proposition covering all Python number types (int, float, Fraction, complex, etc.) and listing all characters. Maybe a PEP would make sense.
History
Date User Action Args
2021-03-20 14:41:27vstinnersetrecipients: + vstinner, rhettinger, terry.reedy, mark.dickinson, ezio.melotti, serhiy.storchaka, weightwatchers-carlanderson
2021-03-20 14:41:27vstinnersetmessageid: <1616251287.8.0.603906849027.issue43520@roundup.psfhosted.org>
2021-03-20 14:41:27vstinnerlinkissue43520 messages
2021-03-20 14:41:27vstinnercreate