[issue43520] Make Fraction(string) handle non-ascii slashes

2021-04-27 Thread STINNER Victor
Change by STINNER Victor : -- nosy: -vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43520] Make Fraction(string) handle non-ascii slashes

2021-04-24 Thread Frédéric Grosshans-André
Frédéric Grosshans-André added the comment: @Gregory P. Smith unicodedata.numeric, in the sdandard library, already handles non-Ascii fractions in many scripts. The current “problem” is it outputs a float (even for integers): >>> unicodedata.numeric('⅔') 0. The

[issue43520] Make Fraction(string) handle non-ascii slashes

2021-03-23 Thread Carl Anderson
Carl Anderson added the comment: >The proposal I like is for a unicode numeric normalization functions that >return the ascii equivalent to exist. @Gregory P. Smith this makes sense to me. That does feel like the cleanest solution. I'm currently doing s = s.replace("⁄","/") but it would be

[issue43520] Make Fraction(string) handle non-ascii slashes

2021-03-22 Thread Carl Anderson
Carl Anderson added the comment: >Carl: can you say more about the problem that motivated this issue? @mark.dickinson I was parsing a large corpus of ingredients strings from web-scraped recipes. My code to interpret strings such as "1/2 cup sugar" would fall over every so often due to

[issue43520] Make Fraction(string) handle non-ascii slashes

2021-03-20 Thread Gregory P. Smith
Change by Gregory P. Smith : -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue43520] Make Fraction(string) handle non-ascii slashes

2021-03-20 Thread Gregory P. Smith
Gregory P. Smith added the comment: The proposal I like is for a unicode numeric normalization functions that return the ascii equivalent to exist. These ideally belong in a third party PyPI library anyways, as they're the kind of thing that needs updating every time a new unicode revision

[issue43520] Make Fraction(string) handle non-ascii slashes

2021-03-20 Thread STINNER Victor
STINNER Victor added the comment: 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

[issue43520] Make Fraction(string) handle non-ascii slashes

2021-03-20 Thread Mark Dickinson
Mark Dickinson added the comment: Carl: can you say more about the problem that motivated this issue? -- ___ Python tracker ___

[issue43520] Make Fraction(string) handle non-ascii slashes

2021-03-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It would be nice to have an utility function in unicodedata to convert Unicode characters to their ASCII equivalents (if they exist). It would allow to explicitly convert all slashes to / (and all digits to 0-9) before passing string to Fraction

[issue43520] Make Fraction(string) handle non-ascii slashes

2021-03-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: Dr Racket supports fraction conversions but insists on a forward slash just like we do. Welcome to DrRacket, version 7.9.0.17--2020-12-24(f6b7f93/a) [cs]. Language: racket, with debugging; memory limit: 128 MB. > (/ 1 2) 1/2 > (string->number "3/5") 3/5 >

[issue43520] Make Fraction(string) handle non-ascii slashes

2021-03-19 Thread Terry J. Reedy
Terry J. Reedy added the comment: I agree with Raymond, at least for now. I would expect the string argument to Fraction to be quoted legal Python code. Without a lot of thought and discussion leading to a change in python design with respect to unicode and operators, this limits '/' to