1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (c) 2003-2018 by The University of Queensland
% http://www.uq.edu.au
%
% Primary Business: Queensland, Australia
% Licensed under the Apache License, version 2.0
% http://www.apache.org/licenses/LICENSE-2.0
%
% Development until 2012 by Earth Systems Science Computational Center (ESSCC)
% Development 2012-2013 by School of Earth Sciences
% Development from 2014 by Centre for Geoscience Computing (GeoComp)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Python3 Support}\label{app:py3}
\textbf{We are not dropping support for recent \pythontwo releases, \textsl{yet}.} ($2.7$ or later is still supported) \\
All we are doing is preparing for the time when \pythonthree is used more widely.
\escript compiles and passes tests under \pythonthree.
However, some packages which can be used by \escript may not have precompiled packages for \pythonthree available yet.
This can be because the changes needed to support \pythonthree have not made it into the
release branch yet.
In the case of some Linux distributions, some packages are not built for \pythonthree yet.
Regardless, if you wish to use \escript with \pythonthree, you will need to compile it (and perhaps some of
its dependencies) yourself.
See the install guide for more details.
\section{Impact on scripts}
We have attempted to minimise disruption and caused by supporting both \pythontwo and \pythonthree.
As long as your scripts work under the \pythontwo you don't \emph{need} to change anything.
However, you might consider the following:
\begin{itemize}
\item Use \texttt{//} for division where you expect an integer answer.
In \pythonthree, \texttt{/} always produces a floating point answer\footnote{Division involving escript types (eg \texttt{Data}) has always produced floating point answers.
.}.
To use this behaviour now, add the following to the top of your script:\\
\texttt{from __future__ import division}
\item Use \texttt{print} as a function rather than a statement.
That is: \texttt{print("x", x)} instead of \texttt{print "x",x}.
To enable this in \pythontwo add \texttt{from __future__ import print_function} to the top of your script.
\item{Don't use \verb|<tabs>| for indentation. The \texttt{expand} utility can help here.}
\end{itemize}
In our experience, many (but not all) changes required to get simple scripts working under \pythonthree will also
work under \pythontwo.
For more information about the differences in the languages see \url{http://wiki.python.org/moin/Python2orPython3}
or \url{http://docs.python.org/py3k/whatsnew/3.0.html}.
|