This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ** in doc/current/lib/operator-map.html
Type: Stage:
Components: Extension Modules Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: gvanrossum, jbaddor, rhettinger, tim.peters
Priority: normal Keywords:

Created on 2002-07-04 18:12 by jbaddor, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
operator.diff rhettinger, 2002-08-19 00:03 Patch to operator.c
Messages (6)
msg11476 - (view) Author: Jean-Bernard ADDOR (jbaddor) Date: 2002-07-04 18:12
I would like to see the ** operator included in the
table at

http://www.python.org/doc/current/lib/operator-map.html

with an explanation why it has not been included in the
module operator.

Thank you,

	Jean-Bernard
msg11477 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2002-07-17 02:45
Logged In: YES 
user_id=31435

x**y is the same as pow(x, y).  pow() is a builtin function.  
There's no need to duplicate it in the operator module.
msg11478 - (view) Author: Jean-Bernard ADDOR (jbaddor) Date: 2002-07-17 13:45
Logged In: YES 
user_id=573194

1. I propose it to be included in the table with a note, for
completness.

2. It has to be imported from math or Numeric or MA
(MaskedArray) with different behaviour in each case. As a
consequence it results better for me
to avoid the import from a specific package and use the
operator wich gives always what we expect, even with
argument of different types an operator wich could hide
these differences would be useful at least for me.

>>> math.pow(3,4)
81.0

>>> Numeric.power(Numeric.arange(5),2)
array([ 0,  1,  4,  9, 16])

>>> math.pow(Numeric.arange(5),2)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: only rank-0 arrays can be converted to Python
scalars.

>>> Numeric.arange(5)**2
array([ 0,  1,  4,  9, 16])

>>> 3**4
81

Python 2.0 (#9, Feb  2 2001, 12:17:02) 
[GCC 2.95.2 19991024 (release)] on linux2
>>> print Numeric.__version__ 
17.2.0

msg11479 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-08-19 00:03
Logged In: YES 
user_id=80475

Tim's right that __builtins__.pow() meets any need well 
enough.  It does raise the question of how operator.abs() 
made it in though it duplicates __builtins__.abs().

OTOH, the operator module does purport to have an 
equivalent for every operator and it would be nice to have 
a complete table.  In that spirit, an operator.c patch is 
attached.  If approved, I'll add the docs and unittests to 
Python 2.3 (don't think it belongs in 2.2).

GvR, please bless or curse this one so we can close it.
msg11480 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-08-19 01:01
Logged In: YES 
user_id=6380

"Bless".
msg11481 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-08-19 03:20
Logged In: YES 
user_id=80475

Jean-Bernard, thank you for the submission. 

Committed as:
operator.c 2.24
liboperator.tex 1.22
test_operator.py 1.10

Closing bug.
History
Date User Action Args
2022-04-10 16:05:29adminsetgithub: 36850
2002-07-04 18:12:37jbaddorcreate