mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Added __pow__(a,b) to the operator module. Completes the pattern of
all operators having a counterpart in the operator module. Closes SF bug #577513.
This commit is contained in:
parent
7dca21e59f
commit
5959c559df
3 changed files with 23 additions and 0 deletions
|
@ -101,6 +101,15 @@ spamrc(op_ne , Py_NE)
|
|||
spamrc(op_gt , Py_GT)
|
||||
spamrc(op_ge , Py_GE)
|
||||
|
||||
static PyObject*
|
||||
op_pow(PyObject *s, PyObject *a)
|
||||
{
|
||||
PyObject *a1, *a2;
|
||||
if (PyArg_ParseTuple(a,"OO:pow",&a1,&a2))
|
||||
return PyNumber_Power(a1, a2, Py_None);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
op_getslice(PyObject *s, PyObject *a)
|
||||
{
|
||||
|
@ -199,6 +208,7 @@ spam2(setitem,__setitem__,
|
|||
"setitem(a, b, c) -- Same as a[b] = c.")
|
||||
spam2(delitem,__delitem__,
|
||||
"delitem(a, b) -- Same as del a[b].")
|
||||
spam2(pow,__pow__, "pow(a, b) -- Same as a**b.")
|
||||
spam2(getslice,__getslice__,
|
||||
"getslice(a, b, c) -- Same as a[b:c].")
|
||||
spam2(setslice,__setslice__,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue