Use print as a function

parent 043bc0eb
......@@ -48,7 +48,7 @@ Common sources of bugs
return a
x = np.ones(5)
print double(x) # x[:] is now 2.
print(double(x)) # x[:] is now 2.
- Forgetting a ``n += 1`` statement in a for loop::
......
......@@ -7,7 +7,7 @@ Debugging
Python debugging
================
Even though some debugging can done just with print statements, a real
Even though some debugging can done just with the print function, a real
debugger offers several advantages. It is possible, for example, to set
breakpoints in certain files or functions, execute the code step by step,
examine and change values of variables. Python contains a standard debugger
......
......@@ -98,7 +98,7 @@ Exciting the LUMO in CO::
E_es = CO.get_potential_energy()
print 'Excitation energy: ', E_es-E_gs
print('Excitation energy: ', E_es - E_gs)
The commented line ``lumo = dscf.Molecular...``
uses another class to specify the `2\pi` orbital of CO which does not require
......
......@@ -1029,7 +1029,7 @@ at a later time, this can be done as follows:
>>> from gpaw import *
>>> atoms, calc = restart('H2.gpw')
>>> print atoms.get_potential_energy()
>>> print(atoms.get_potential_energy())
Everything will be just as before we wrote the :file:`H2.gpw` file.
Often, one wants to restart the calculation with one or two parameters
......@@ -1037,14 +1037,14 @@ changed slightly. This is very simple to do. Suppose you want to
change the number of grid points:
>>> atoms, calc = restart('H2.gpw', gpts=(20, 20, 20))
>>> print atoms.get_potential_energy()
>>> print(atoms.get_potential_energy())
.. tip::
There is an alternative way to do this, that can be handy sometimes:
>>> atoms, calc = restart('H2.gpw')
>>> calc.set(gpts=(20, 20, 20))
>>> print atoms.get_potential_energy()
>>> print(atoms.get_potential_energy())
More details can be found on the :ref:`restart_files` page.
......
......@@ -67,7 +67,7 @@ makes ``thing`` available. Lets try an example:
* and in file :file:`program.py`, put::
from stuff import constant, function
print 'result =', function(constant)
print('result =', function(constant))
* Now run the script :file:`program.py` and watch the output.
......
......@@ -188,7 +188,7 @@ Try to subdiagonalize the molecular subspace::
bfs = range(bf_H1, bf_H1 + 2 * H_nbf)
h_rot, s_rot, eps_n, vec_jn = tcalc.subdiagonalize_bfs(bfs)
for n in range(len(eps_n)):
print 'bf %i correpsonds to the eigenvalue %.2f eV' % (bfs[n],eps_n[n])
print('bf %i correpsonds to the eigenvalue %.2f eV' % (bfs[n],eps_n[n]))
Argue that ``vec_jn[:,0]`` and ``vec_jn[:,1]`` corresponds to the bonding and
anti-bonding molecular hydrogen orbitals, respectively.
......
......@@ -191,7 +191,7 @@ Test python/numpy::
from numpy.core.multiarray import dot
b = numpy.ones(13, numpy.complex)
d = dot(b, b)
print 'Hello'
print('Hello')
numpy.test()
EOF
......
......@@ -23,7 +23,7 @@ Setup the root directory::
mkdir -p ${APPHOME}
cd ${APPHOME}
export GPAW_PLATFORM=`python -c "from distutils import util, sysconfig; print util.get_platform()+'-'+sysconfig.get_python_version()"`
export GPAW_PLATFORM=`python -c "from distutils import util, sysconfig; print(util.get_platform()+'-'+sysconfig.get_python_version())"`
Download software::
......
......@@ -24,7 +24,7 @@ Setup the root directory::
mkdir -p ${HOMESOFTS}
cd ${HOMESOFTS}
setenv GPAW_PLATFORM `python -c "from distutils import util, sysconfig; print util.get_platform()+'-'+sysconfig.get_python_version()"`
setenv GPAW_PLATFORM `python -c "from distutils import util, sysconfig; print(util.get_platform()+'-'+sysconfig.get_python_version())"`
Set the versions::
......
......@@ -33,7 +33,7 @@ and create sh startup script::
cat <<EOF > ${HOME}/opt/campos.sh
#!/bin/sh
#
export GPAW_PLATFORM=`python -c "from distutils import util, sysconfig; print util.get_platform()+'-'+sysconfig.get_python_version()"`
export GPAW_PLATFORM=`python -c "from distutils import util, sysconfig; print(util.get_platform()+'-'+sysconfig.get_python_version())"`
#
export LD_LIBRARY_PATH=\${HOME}/opt/acml-${acml}/gfortran64/lib:\${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=\${HOME}/opt/CBLAS.acml-${acml}/lib:\${LD_LIBRARY_PATH} # if cblas used
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment