You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fraction constructor may accept spaces around '/' #88512
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2021-06-08.08:29:36.097>labels= ['library', '3.11']
title="Fraction constructor may accept spaces around '/'"updated_at=<Date2021-06-09.07:04:43.200>user='https://github.com/skirpichev'
Of course, I'm for it. But we have to be consistent... I was surprised to realize complex doesn't accept '2 + 3j' (even though it accepts '(2+3j)', and even '\n2+3j\t'). There are a lot of slippery slopes here (e.g. how about 3_j?). I think that once we allowed _ in integer literals, suddenly we could add more separation between digits than around them in many contexts, and that just seems wrong.
skirpichev commented on Jun 9, 2021
skirpichevmannequin
MannequinAuthor
More actions
On Wed, Jun 09, 2021 at 06:18:22AM +0000, Vedran Čačić wrote:
I was surprised to realize complex doesn't accept '2 + 3j'
Good catch, probably that should be allowed too.
e.g. how about 3_j?
The PEP-515 added '_' as a separator between digits. But the
imaginary unit is not a digit. For same reason '1_/2' shouldn't
be allowed for the Rational constructor. (Unfortunately, the
Decimal class breaks this PEP convention as well as some other,
see bpo-44267. For example, it accepts things like '1._2'.)
Activity
skirpichev commentedon Jun 8, 2021
Per https://bugs.python.org/msg394731 suggestion.
For instance, mpq_set_str() does support this. Also, gmpy2.mpq().
Tentative patch attached.
vedgar commentedon Jun 9, 2021
Of course, I'm for it. But we have to be consistent... I was surprised to realize
complexdoesn't accept '2 + 3j' (even though it accepts '(2+3j)', and even '\n2+3j\t'). There are a lot of slippery slopes here (e.g. how about 3_j?). I think that once we allowed _ in integer literals, suddenly we could add more separation between digits than around them in many contexts, and that just seems wrong.skirpichev commentedon Jun 9, 2021
On Wed, Jun 09, 2021 at 06:18:22AM +0000, Vedran Čačić wrote:
Good catch, probably that should be allowed too.
The PEP-515 added '_' as a separator between digits. But the
imaginary unit is not a digit. For same reason '1_/2' shouldn't
be allowed for the Rational constructor. (Unfortunately, the
Decimal class breaks this PEP convention as well as some other,
see bpo-44267. For example, it accepts things like '1._2'.)
mdickinson commentedon Jun 9, 2021
See previous discussion in bpo-9574.
skirpichev commentedon Jun 9, 2021
Given this, probably spaces around '/' should be disallowed.
mdickinson commentedon Sep 4, 2022
Implemented in #96496.