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
Hristo, python is a duck typing language. You should not have to care about the type of a variable as long as it does what's intended. Seeking consistency where none is required will just end up being huge waste of everyone's time.
If you're so convinced in the rightness of your opinion, please take it to python-ideas mailing list and have it discussed there first before re-opening issue in the future.
type( A(1) % A(2) ) is A
type( A(1) % A(-2) ) is int
type( A(-1) % A(-2) ) is A
type( A(2) % A(1) ) is int
type( A(1) % A(2**30+2) ) is A
type( A(2**30+1) % A(2**30+2) ) is int
type( A(2**15+1) % A(2**15+2) ) is (A if 64bit else int)
Activity
hvenev commentedon Jan 6, 2016
Should be 1. This comes from the (a%b=a if a<b) optimization.
Let's be consistent with all other arithmetic operations.
[-]True%2==True[/-][+]True%2 is True[/+]SilentGhost commentedon Jan 6, 2016
Arithmetic operations should not be used with booleans, they happen to work due to boolean bean a subclass of int.
hvenev commentedon Jan 7, 2016
OK.
SilentGhost commentedon Jan 7, 2016
Hristo, python is a duck typing language. You should not have to care about the type of a variable as long as it does what's intended. Seeking consistency where none is required will just end up being huge waste of everyone's time.
If you're so convinced in the rightness of your opinion, please take it to python-ideas mailing list and have it discussed there first before re-opening issue in the future.
hvenev commentedon Jan 7, 2016
One last thing: type(a%b) is A, type(b%a) is int.
hvenev commentedon Jan 7, 2016
type( A(1) % A(2) ) is A
type( A(1) % A(-2) ) is int
type( A(-1) % A(-2) ) is A
type( A(2) % A(1) ) is int
type( A(1) % A(2**30+2) ) is A
type( A(2**30+1) % A(2**30+2) ) is int
type( A(2**15+1) % A(2**15+2) ) is (A if 64bit else int)