[issue32626] Subscript unpacking raises SyntaxError

2018-01-22 Thread Ben Burrill

New submission from Ben Burrill :

PEP 448 defines unpacking generalizations for tuples.  However, this does not 
currently work for subscripted tuples that are not delimited by parentheses.

Current behavior (Tested on 3.6/3.7a4):
>>> class Subscriptable:
... def __getitem__(self, item):
... return item
...
>>> ss = Subscriptable()
>>> 
>>> 1, 2, 3
(1, 2, 3)
>>> ss[1, 2, 3]
(1, 2, 3)
>>> *range(5), 42
(0, 1, 2, 3, 4, 42)
>>> ss[*range(5), 42]  # This should be the same as above
  File "", line 1
ss[*range(5), 42]
   ^
SyntaxError: invalid syntax
>>> ss[(*range(5), 42)]  # Workaround
(0, 1, 2, 3, 4, 42)

--
components: Interpreter Core
messages: 310447
nosy: Ben Burrill
priority: normal
severity: normal
status: open
title: Subscript unpacking raises SyntaxError
type: behavior
versions: Python 3.7

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



[issue32626] Subscript unpacking raises SyntaxError

2018-01-26 Thread Ben Burrill

Ben Burrill  added the comment:

Yeah, but in this case, you don't need parentheses unless you use unpacking.  
That is unexpected behavior.

--

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



[issue31707] Irrational fractions

2017-10-05 Thread Ben Burrill

New submission from Ben Burrill :

fractions.Fraction enforces its numerator and denominator to be rational.  This 
is a good idea for purely numeric fractions, but the abstractions that 
fractions.Fraction offers would also be useful for more abstract fractions.

Some places where this might be useful would be fractions of polynomial types 
or fractions with abstract irrational numeric types, like F(SquareRoot(3), 2).

This could be accomplished by having a more general Fraction superclass or by 
removing the requirement of rationality from fractions.Fraction.  It is not 
trivial to create a subclass of Fraction that does this because the operators 
are hardcoded to use Fraction and initiation is done in __new__.

--
components: Library (Lib)
messages: 303788
nosy: Ben Burrill
priority: normal
severity: normal
status: open
title: Irrational fractions
type: behavior
versions: Python 3.6

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



[issue31707] Irrational fractions

2017-10-05 Thread Ben Burrill

Change by Ben Burrill :


--
nosy: +mark.dickinson, rhettinger

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



[issue31707] Irrational fractions

2017-10-05 Thread Ben Burrill

Ben Burrill  added the comment:

The core operators, like multiplication and division, should work for any type 
that defines the right operators.  Hashing is tricky, and reducing the fraction 
is pretty much off the table.  This is why I suggested a superclass.  I'll try 
making a patch sometime soon.

I am aware of sympy and am not proposing that the standard library stray too 
far into symbolic mathematics.  Sympy's re-invention of the fraction makes 
sense given sympy's scope, but simpler libraries that offer other abstract math 
features (like one that just implemented a simple Polynomial type) would 
benefit from using fractions.Fraction.

This change would probably make it so that sympy symbols worked with 
fractions.Fraction, which although unnecessary, might be nice.

--

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