[Python-bugs-list] [ python-Bugs-577513 ] ** in doc/current/lib/operator-map.html

noreply@sourceforge.net noreply@sourceforge.net
Sun, 18 Aug 2002 17:03:35 -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: Open
Resolution: None
Priority: 5
Submitted By: Jean-Bernard ADDOR (jbaddor)
>Assigned to: Guido van Rossum (gvanrossum)
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 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