[issue43520] Fraction only handles regular slashes ("/") and fails with other similar slashes

2021-03-16 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

I think we should stick the with forward slashes.  That is what the rest of the 
language does.  Adding more options is recipe for confusion.

>>> 38 / 5
7.6
>>> 38 ∕ 5
SyntaxError: invalid character '∕' (U+2215)

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43520] Fraction only handles regular slashes ("/") and fails with other similar slashes

2021-03-16 Thread Carl Anderson

Carl Anderson  added the comment:

I guess if we are doing slashes, then the division sign ÷ (U+00F7) should be 
included too. 

There are at least 2 minus signs too (U+002D, U+02D7).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43520] Fraction only handles regular slashes ("/") and fails with other similar slashes

2021-03-16 Thread Ezio Melotti


Change by Ezio Melotti :


--
nosy: +ezio.melotti

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43520] Fraction only handles regular slashes ("/") and fails with other similar slashes

2021-03-16 Thread Carl Anderson

Carl Anderson  added the comment:

from https://en.wikipedia.org/wiki/Slash_(punctuation) there is

U+002F / SOLIDUS
U+2044 ⁄ FRACTION SLASH
U+2215 ∕ DIVISION SLASH
U+29F8 ⧸ BIG SOLIDUS
U+FF0F / FULLWIDTH SOLIDUS (fullwidth version of solidus)
U+1F67C  VERY HEAVY SOLIDUS

In XML and HTML, the slash can also be represented with the character entity 
 or  or .[42]

there are a couple more listed here:

https://unicode-search.net/unicode-namesearch.pl?term=SLASH

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43520] Fraction only handles regular slashes ("/") and fails with other similar slashes

2021-03-16 Thread Mark Dickinson


Mark Dickinson  added the comment:

Related: #6632

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43520] Fraction only handles regular slashes ("/") and fails with other similar slashes

2021-03-16 Thread Mark Dickinson

Mark Dickinson  added the comment:

Seems worth noting that Unicode fractions like ⅔ produce a FRACTION SLASH 
character when normalized:

>>> unicodedata.normalize('NFKC', '⅔')
'2⁄3'
>>> list(map(unicodedata.name, unicodedata.normalize('NFKC', '⅔')))
['DIGIT TWO', 'FRACTION SLASH', 'DIGIT THREE']

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43520] Fraction only handles regular slashes ("/") and fails with other similar slashes

2021-03-16 Thread Mark Dickinson

Mark Dickinson  added the comment:

There's a bigger issue here about what characters should be accepted in numeric 
literals. The Unicode minus sign (U+2212) "−" is also not currently accepted 
for Fractions or any other built-in numeric type.

> but there are other similar slashes such as (0x2044) in which it throws an 
> error

Do you have a proposal for the set of slashes that should be accepted, or a 
non-arbitrary rule for determining that set?  U+2044 (FRACTION SLASH), U+2215 
(DIVISION SLASH) and U+FF0F (FULLWIDTH SOLIDUS) all seem like potential 
candidates. Are there others?

--
nosy: +mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43520] Fraction only handles regular slashes ("/") and fails with other similar slashes

2021-03-16 Thread Carl Anderson

New submission from Carl Anderson :

Fraction works with a regular slash:

>>> from fractions import Fraction
>>> Fraction("1/2")
Fraction(1, 2)

but there are other similar slashes such as (0x2044) in which it throws an 
error:

>>> Fraction("0⁄2")
Traceback (most recent call last):
  File "", line 1, in 
  File "/opt/anaconda3/lib/python3.7/fractions.py", line 138, in __new__
numerator)
ValueError: Invalid literal for Fraction: '0⁄2'


This seems to come from the (?:/(?P\d+))? section of the regex 
_RATIONAL_FORMAT in fractions.py

--
components: Library (Lib)
messages: 388865
nosy: weightwatchers-carlanderson
priority: normal
severity: normal
status: open
title: Fraction only handles regular slashes ("/") and fails with other similar 
slashes
type: enhancement
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com