[Python-bugs-list] [ python-Bugs-577513 ] ** in doc/current/lib/operator-map.html
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 18 Aug 2002 20:20:46 -0700
Bugs item #577513, was opened at 2002-07-04 13:12
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=577513&group_id=5470
Category: Extension Modules
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Jean-Bernard ADDOR (jbaddor)
Assigned to: Raymond Hettinger (rhettinger)
Summary: ** in doc/current/lib/operator-map.html
Initial Comment:
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
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2002-08-18 22:20
Message:
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.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-08-18 20:01
Message:
Logged In: YES
user_id=6380
"Bless".
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2002-08-18 19:03
Message:
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.
----------------------------------------------------------------------
Comment By: Jean-Bernard ADDOR (jbaddor)
Date: 2002-07-17 08:45
Message:
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
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-07-16 21:45
Message:
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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=577513&group_id=5470