[Python-Dev] "result type only depends on operand types"...?
Tim Peters
tim.one@comcast.net
Sun, 31 Mar 2002 13:14:45 -0500
[Guido]
> 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.
[Alex Martelli]
> And yet...:
>
> >>> type(2**10)
> <type 'int'>
> >>> type(2**100)
> <type 'long'>
>
> ...doesn't this apply to many operators on ints in 2.2?
Yes indeed.
> Yet _another_ (set of) exception(s) with practicality beating purity?
In this case, you're looking at a transitional stage in a *change* to
Python's type system, eventually eliminating the int/long distinction. 2.2
implemented PEP 237's Phase A; there's more to come, spread out over years:
http://python.sourceforge.net/peps/pep-0237.html
> Perhaps, but if a "very general rule" has so many exceptions in
> frequent and fundamental cases, is it a rule at all...?
Maybe a rule so general is better thought of as a guiding principle. Like
"one man, one vote", we eventually made exceptions of inclusion and
exclusion for women, felons, and people with a lot of money <wink>.
the-laws-of-gravity-don't-apply-ly y'rs - tim