__rcall__???

Tim Peters tim_one at email.msn.com
Thu Dec 30 01:09:27 EST 1999


[David C. Ullrich]
> ... I must be a version behind again or something, "Emulating numeric
> types" is 3.3.5 here.

The current docs are always available on the web; note that they get updated
independently of-- and more often than --interpreter releases.   Try:

    http://www.python.org/doc/current/ref/numeric-types.html

> Before I spend time trying to catch up: Are you saying that
> the current 3.3.6 tells the full story, including the answer to
> the question I asked about the _history_, when __rpow__ was
> introduced?

No, there's no info in the manual about the history.  Misc/HISTORY (from the
source distribution) doesn't say anything about rpow either.  If it really
matters to you when __rpow__ got introduced, you'll have to ask someone at
CNRI to dig thru old CVS diffs.

>> ... __pow__ takes an optional 3rd argument,

> Again, does it? A few weeks ago 1.5.2 was the latest version
> - there the docs say that __pow__ takes a third argument but
> the interpreter disagrees.  Well, of course I can make __rpow__
> take whatever arguments I like, but the point is to implement
> pow, and pow seems to barf on a third argument:
>
> >>> pow(2,2)
> 4.0
> >>> pow(2,2,2)
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
> TypeError: 2-sequence, 3-sequence
> >>>
>
> This would be the Windows 1.5.2.

I suspect you shot yourself in the foot by doing something like

    from math import *

without admitting to it <wink>.  "import *" is evil.  math.pow is not
__builtin__.pow; only the latter is hooked by __pow__ methods; math.pow,
like the rest of math, is just a thin wrapper around your vendor's libm (or
moral equivalent).

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
IDLE 0.5 -- press F1 for help
>>> pow(2, 17388, 17389)  # in honor of the season, the 2000th prime
1
>>> pow
<built-in function pow>
>>> from math import pow
>>> pow(2, 17388, 17389)
Traceback (innermost last):
  File "<pyshell#3>", line 1, in ?
    pow(2, 17388, 17389)
TypeError: 2-sequence, 3-sequence
>>>

> ... there are no Functions that take more than one parameter. (It's
> supposed to be a math thing - "officially" there's no such thing as
> a function of two variables in mathematics either, "officially" they
> get emulated by functions of one variable.)

This explains why Guido is agonizing over whether Python2 should represent
integers as nested sets or via lambda composition <wink>.

in-a-language-with-curried-functions-rcall-could-be-natural-ly y'rs
    - tim






More information about the Python-list mailing list