__rcall__???

Robert Kern kern at caltech.edu
Wed Dec 22 01:43:24 EST 1999


On Tue, 21 Dec 1999 11:31:34 -0600, "David C. Ullrich"
<ullrich at math.okstate.edu> wrote:

>
>
>Tim Peters wrote:
>
>> [...]
>>
>> >     What's the story on __rpow__, natural-wise? I have a book that
>> > lists all the magic methods but leaves out __rpow__. Was that
>> > just an omission in the book, or did __rpow__ get added some time
>> > after version 1.3 (the version in the book)?
>>
>> 1.3 predates my reliable memory -- if I'm not mistaken, that's even earlier
>> than 1.4, which latter not even Guido remembers <wink>.  Section 3.3.6
>> ("Emulating numeric types") of a current Language Reference Manual tells the
>> full story on __rpow__.
>
>    Does it? I must be a version behind again or something, "Emulating numeric
>types" is 3.3.5 here. 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.  Try looking in the ChangeLog and HISTORY files in the source
distribution for the history.  And, FWIW, you are a version behind on
the documentation.

>>
>> >     If the latter, I'd like to say that when I saw no __rpow__ in
>> > the book I decided I couldn't do what I was trying to do that day
>> > (I've got my own clumsy __rcall__ working but I don't know how
>> > I'd do __rpow__ by hand the same way) - when I found __rpow__
>> > in the docs I decided that project was doable. It seems clear that
>> > there's no need for an __rpow__, but I've used it several times.
>>
>> __rpow__ is clearly needed to implement new "numeric" types, which latter
>> many people did ask for.  Note that it's a bit of a strain, though:  __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 read that the next version
>would be 1.6 and it wasn't due for a while - am I behind again
>or what?

Not sure.  This is what I get (Windows 1.5.2, freshly downloaded):

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> pow(2,2)
4
>>> pow(2,2,2)
0
>>>

[snip]

Robert Kern
kern at caltech.edu



More information about the Python-list mailing list