ViewVC logotype

Annotation of /trunk/doc/user/py3.tex

Parent Directory Parent Directory | Revision Log Revision Log

Revision 6651 - (hide annotations)
Wed Feb 7 02:12:08 2018 UTC (18 months, 2 weeks ago) by jfenwick
File MIME type: application/x-tex
File size: 2684 byte(s)
Make everyone sad by touching all the files

Copyright dates update

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

  ViewVC Help
Powered by ViewVC 1.1.26