A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-March/022010.html below:

[Python-Dev] "result type only depends on operand types"...?

[Python-Dev] "result type only depends on operand types"...? [Python-Dev] "result type only depends on operand types"...?Alex Martelli aleax@aleax.it
Sun, 31 Mar 2002 18:38:58 +0100
Back on March 10 in the thread on PEP 285 Guido wrote:

"""
This is a very general rule that I like a lot: that the type of a
result should only depend on the type of the arguments, not on their
values.  I expect that this rule will make reasoning about programs
(as in PsyCo or PyChecker) easier to do.

I recently caved in and allowed an exception: 2**2 returns an int, but
2**-2 returns a float.  This was a case of "practicality beats
purity".  I don't see True-1 in the same league though.
"""

And yet...:

>>> type(2**10)
<type 'int'>
>>> type(2**100)
<type 'long'>

...doesn't this apply to many operators on ints in 2.2?  Yet _another_
(set of) exception(s) with practicality beating purity?  Perhaps, but if a 
"very general rule" has so many exceptions in frequent and fundamental
cases, is it a rule at all...?


Alex



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4