From 4ea9be3c1897b5742db91adcae26db8b14c2c724 Mon Sep 17 00:00:00 2001 From: Scott Sievert Date: Thu, 14 Jul 2016 14:02:56 -0500 Subject: [PATCH 1/4] clarifies can make code run under 2 and 3 --- python3_user_transition_guide.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/python3_user_transition_guide.rst b/python3_user_transition_guide.rst index cda5cbb..7b61131 100644 --- a/python3_user_transition_guide.rst +++ b/python3_user_transition_guide.rst @@ -4,6 +4,20 @@ Python 3 transition guide Switching to Python 3 can seem like a daunting task, but this guide will provide some tips and resources to help make it more straightforward. +Changes for vanilla Python to support both Python 2 and 3 +--------------------------------------------------------- +Vanilla Python code (i.e., typical scientific code) +does not need much modification to run under *both* Python 2 and Python 3. + +For these scripts, including the line below at the top +of the script makes the script run under both Python 2 and Python 3. + +.. code-block:: python + + from __future__ import print_function, division, absolute_import + +The next section provides an explanation of what this provides. + Changes you can make today to make the transition easier -------------------------------------------------------- From 5930d1ea5256a22e8f6f64e07a0887d25667a242 Mon Sep 17 00:00:00 2001 From: Scott Sievert Date: Thu, 14 Jul 2016 16:26:04 -0500 Subject: [PATCH 2/4] removes add'l section on single-line switch --- python3_user_transition_guide.rst | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/python3_user_transition_guide.rst b/python3_user_transition_guide.rst index 7b61131..0810ae0 100644 --- a/python3_user_transition_guide.rst +++ b/python3_user_transition_guide.rst @@ -4,19 +4,6 @@ Python 3 transition guide Switching to Python 3 can seem like a daunting task, but this guide will provide some tips and resources to help make it more straightforward. -Changes for vanilla Python to support both Python 2 and 3 ---------------------------------------------------------- -Vanilla Python code (i.e., typical scientific code) -does not need much modification to run under *both* Python 2 and Python 3. - -For these scripts, including the line below at the top -of the script makes the script run under both Python 2 and Python 3. - -.. code-block:: python - - from __future__ import print_function, division, absolute_import - -The next section provides an explanation of what this provides. Changes you can make today to make the transition easier -------------------------------------------------------- From 0383da17aa9aa1c8d3a082fac0e96ffa00301b3e Mon Sep 17 00:00:00 2001 From: Scott Sievert Date: Thu, 14 Jul 2016 16:35:26 -0500 Subject: [PATCH 3/4] header change, splitting paragraph --- python3_user_transition_guide.rst | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/python3_user_transition_guide.rst b/python3_user_transition_guide.rst index 0810ae0..260ccf2 100644 --- a/python3_user_transition_guide.rst +++ b/python3_user_transition_guide.rst @@ -5,16 +5,17 @@ Switching to Python 3 can seem like a daunting task, but this guide will provide some tips and resources to help make it more straightforward. -Changes you can make today to make the transition easier --------------------------------------------------------- - +Writing Python 3 compatible code +--------------------------------------------- Any new code you write can easily be Python 3 compatible! This is the first step -you can take towards switching. Thankfully, the most disruptive changes to the -language have been back-ported to Python 2 so you can ensure that, when writing +you can take towards switching. For scientific scripts, being Python 3 combatible +tends to imply Python 2 compatability. + +Thankfully, the most disruptive changes to the +language have been back-ported to Python 2 so you can ensure that when writing new code that you intend to execute with Python 2, it will be executable in Python 3 once you switch. To use these back-ported changes, you must import -certain utilities from the built-in ```__future__`` -`_ package. It is generally +certain utilities from the built-in ``__future__`` package. It is generally recommended that, if you are still writing Python 2 compatible code, you should import the following four modules in any code you write:: From 299edff01a2ec597cae99b0613c4d33806ee1a75 Mon Sep 17 00:00:00 2001 From: Scott Sievert Date: Thu, 14 Jul 2016 16:52:00 -0500 Subject: [PATCH 4/4] renames page, removes first "daunting" paragraph "transition guide" --> "python 3 compatible" --- python3_user_transition_guide.rst | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/python3_user_transition_guide.rst b/python3_user_transition_guide.rst index 260ccf2..c4df530 100644 --- a/python3_user_transition_guide.rst +++ b/python3_user_transition_guide.rst @@ -1,12 +1,5 @@ -Python 3 transition guide -========================= - -Switching to Python 3 can seem like a daunting task, but this guide will -provide some tips and resources to help make it more straightforward. - - Writing Python 3 compatible code ---------------------------------------------- +================================ Any new code you write can easily be Python 3 compatible! This is the first step you can take towards switching. For scientific scripts, being Python 3 combatible tends to imply Python 2 compatability.