summaryrefslogtreecommitdiff
path: root/numpy/doc
diff options
context:
space:
mode:
authorgfyoung <gfyoung17@gmail.com>2015-12-19 16:49:35 -0800
committergfyoung <gfyoung17@gmail.com>2015-12-19 16:50:09 -0800
commit8bc592fabf4a2b0bc76db996b1523330ba095be3 (patch)
treec8a1a549e5a093a9433fe9a50a6e0e8bb5358ab1 /numpy/doc
parente2bdaccba1a8691f9223b059b981b2890bb13b09 (diff)
downloadpython-numpy-8bc592fabf4a2b0bc76db996b1523330ba095be3.tar.gz
python-numpy-8bc592fabf4a2b0bc76db996b1523330ba095be3.tar.bz2
python-numpy-8bc592fabf4a2b0bc76db996b1523330ba095be3.zip
DOC: Use print only as function when print_function is imported from __future__
Closes gh-6863.
Diffstat (limited to 'numpy/doc')
-rw-r--r--numpy/doc/glossary.py6
-rw-r--r--numpy/doc/misc.py2
-rw-r--r--numpy/doc/subclassing.py36
3 files changed, 22 insertions, 22 deletions
diff --git a/numpy/doc/glossary.py b/numpy/doc/glossary.py
index 9dacd1cb5..4a3238491 100644
--- a/numpy/doc/glossary.py
+++ b/numpy/doc/glossary.py
@@ -109,7 +109,7 @@ Glossary
>>> def log(f):
... def new_logging_func(*args, **kwargs):
- ... print "Logging call with parameters:", args, kwargs
+ ... print("Logging call with parameters:", args, kwargs)
... return f(*args, **kwargs)
...
... return new_logging_func
@@ -185,7 +185,7 @@ Glossary
It is often used in combintion with ``enumerate``::
>>> keys = ['a','b','c']
>>> for n, k in enumerate(keys):
- ... print "Key %d: %s" % (n, k)
+ ... print("Key %d: %s" % (n, k))
...
Key 0: a
Key 1: b
@@ -315,7 +315,7 @@ Glossary
... color = 'blue'
...
... def paint(self):
- ... print "Painting the city %s!" % self.color
+ ... print("Painting the city %s!" % self.color)
...
>>> p = Paintbrush()
>>> p.color = 'red'
diff --git a/numpy/doc/misc.py b/numpy/doc/misc.py
index 1709ad66d..e30caf0cb 100644
--- a/numpy/doc/misc.py
+++ b/numpy/doc/misc.py
@@ -86,7 +86,7 @@ Examples
>>> np.sqrt(np.array([-1.]))
FloatingPointError: invalid value encountered in sqrt
>>> def errorhandler(errstr, errflag):
- ... print "saw stupid error!"
+ ... print("saw stupid error!")
>>> np.seterrcall(errorhandler)
<function err_handler at 0x...>
>>> j = np.seterr(all='call')
diff --git a/numpy/doc/subclassing.py b/numpy/doc/subclassing.py
index a62fc2d6d..85327feab 100644
--- a/numpy/doc/subclassing.py
+++ b/numpy/doc/subclassing.py
@@ -123,13 +123,13 @@ For example, consider the following Python code:
class C(object):
def __new__(cls, *args):
- print 'Cls in __new__:', cls
- print 'Args in __new__:', args
+ print('Cls in __new__:', cls)
+ print('Args in __new__:', args)
return object.__new__(cls, *args)
def __init__(self, *args):
- print 'type(self) in __init__:', type(self)
- print 'Args in __init__:', args
+ print('type(self) in __init__:', type(self))
+ print('Args in __init__:', args)
meaning that we get:
@@ -159,13 +159,13 @@ of some other class. Consider the following:
class D(C):
def __new__(cls, *args):
- print 'D cls is:', cls
- print 'D args in __new__:', args
+ print('D cls is:', cls)
+ print('D args in __new__:', args)
return C.__new__(C, *args)
def __init__(self, *args):
# we never get here
- print 'In D __init__'
+ print('In D __init__')
meaning that:
@@ -242,18 +242,18 @@ The following code allows us to look at the call sequences and arguments:
class C(np.ndarray):
def __new__(cls, *args, **kwargs):
- print 'In __new__ with class %s' % cls
+ print('In __new__ with class %s' % cls)
return np.ndarray.__new__(cls, *args, **kwargs)
def __init__(self, *args, **kwargs):
# in practice you probably will not need or want an __init__
# method for your subclass
- print 'In __init__ with class %s' % self.__class__
+ print('In __init__ with class %s' % self.__class__)
def __array_finalize__(self, obj):
- print 'In array_finalize:'
- print ' self type is %s' % type(self)
- print ' obj type is %s' % type(obj)
+ print('In array_finalize:')
+ print(' self type is %s' % type(self))
+ print(' obj type is %s' % type(obj))
Now:
@@ -441,16 +441,16 @@ some print statements:
return obj
def __array_finalize__(self, obj):
- print 'In __array_finalize__:'
- print ' self is %s' % repr(self)
- print ' obj is %s' % repr(obj)
+ print('In __array_finalize__:')
+ print(' self is %s' % repr(self))
+ print(' obj is %s' % repr(obj))
if obj is None: return
self.info = getattr(obj, 'info', None)
def __array_wrap__(self, out_arr, context=None):
- print 'In __array_wrap__:'
- print ' self is %s' % repr(self)
- print ' arr is %s' % repr(out_arr)
+ print('In __array_wrap__:')
+ print(' self is %s' % repr(self))
+ print(' arr is %s' % repr(out_arr))
# then just call the parent
return np.ndarray.__array_wrap__(self, out_arr, context)