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

noreply@sourceforge.net noreply@sourceforge.net
Wed, 17 Jul 2002 06:45:14 -0700


Bugs item #577513, was opened at 2002-07-04 14:12
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=577513&group_id=5470

Category: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Jean-Bernard ADDOR (jbaddor)
Assigned to: Nobody/Anonymous (nobody)
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: Jean-Bernard ADDOR (jbaddor)
Date: 2002-07-17 09: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 22: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