Le 25/01/2021 à 23:52, Nils Bruin a écrit :
On Monday, January 25, 2021 at 7:09:32 AM UTC-8 Nikos Apostolakis wrote:
Dear Nils,
[...] I think treating rational integers as integers is safe. Actually
Sage does that
sage: 8/2 in ZZ
True
So to have a function with integer input throw an error when you feed it a
rational integer, is surprising and counterintuitive. To me at least.
Ah right, Sage takes a rather liberal interpretation of "in" here: since
the target is given, it's apparently read as "can 8/2 be converted to an
integer". I'm neutral on what Words should do with its arguments.
And what should be thought about "4.0 in ZZ" ?
Even more fun
sage: a in ZZ
False
sage: 4 / a in ZZ
False
sage: 4.0 / a in ZZ
True
Does Sage even have any clear specification for "x in P"?
Concerning input that are of the wrong type, it is common
in Python (?) to just throw error
>>> list(range(4))
[0, 1, 2, 3]
>>> list(range(4.0))
Traceback (most recent call last):
...
TypeError: 'float' object cannot be interpreted as an integer
Vincent
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sage-support/527bf9d2-ce9a-6226-4379-04153d5cebd7%40gmail.com.