Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
 
Moving from Python 2.6 to Python 3

Python courseWhen should you move your development to Python 3? When you're good and ready and you're certain that you'll not need to run your code on Python 2 again. Up to that point, the 2to3 utility will convert code for you.

Here's an example where I converted a short example script called "london" - using the -w option to write the file back, moving the old file to a .bak file. You can see in the reports the changes that have been made.

wizard:python graham$ 2to3 -w london
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
--- london (original)
+++ london (refactored)
@@ -2,7 +2,7 @@
 
 vatrates = (15,17.5,20) ;
 
-paid = float(raw_input("Whatdya pay furit? "))
+paid = float(input("Whatdya pay furit? "))
 
 for vatrate in vatrates:
  factor = 100.0 / (100.0 + vatrate)
@@ -10,6 +10,6 @@
  shopkeeper = paid * factor
  osborne = paid - shopkeeper
 
- print "Vat rate",vatrate,", Storeman ",shopkeeper,", Chancellor ",osborne
+ print("Vat rate",vatrate,", Storeman ",shopkeeper,", Chancellor ",osborne)
 
- print "izedone"
+ print("izedone")
RefactoringTool: Files that were modified:
RefactoringTool: london
wizard:python graham$


See [unconverted] and [converted] code.


Picture - delegate on a Python Course earlier this week. (You learn a lot on our courses - and we make them fun! as well.
(written 2010-07-14)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
Y300 - Python 3 - What is new, what's changed and why
  [4712] A reminder of the key issues to consider in moving from Python 2 to Python 3 - (2016-10-30)
  [4711] Convering from Python 2 to Python 3 - an update, and the 2to3 utility - (2016-10-30)
  [4650] Why populate object with values as you construct them? - (2016-02-18)
  [4649] Object and Static methods - what is the difference; example in Python 3 - (2016-02-17)
  [4590] Progress on moving from Python 2 to Python 3 - training for both versions - (2015-12-01)
  [4470] Testing in Python 3 - unittest, doctest and __name__ == __main__ too. - (2015-04-21)
  [4469] Sorting in Python 3 - and how it differs from Python 2 sorting - (2015-04-20)
  [2778] Learning to program in Python 2 ... and / or in Python 3 - (2010-05-24)
  [2559] Moving the product forward - ours, and MySQL, Perl, PHP and Python too - (2010-01-01)
  [2285] Great new diagrams for our notes ... Python releases - (2009-07-13)
  [2277] Python classes / courses - what version do we train on? - (2009-07-10)
  [1791] The road ahead - Python 3 - (2008-09-10)
  [1788] Python 2 to Python 3 / Python 3000 / Py3k - (2008-09-07)
  [753] Python 3000 - the next generation - (2006-06-09)


Back to
Old prices - what would the equivalent price have been in 1966?
Previous and next
or
Horse's mouth home
Forward to
Moved - Melksham Lorry Park
Some other Articles
A long day in Melksham ...
Unpacking a Perl string into a list
Another toot of the trumpet
Moved - Melksham Lorry Park
Moving from Python 2.6 to Python 3
Old prices - what would the equivalent price have been in 1966?
Contact Information for Melksham Oak Community School
A move towards the family
Cycling in Melksham, and looking forward
Ruby - how does it compare and where is it the right language?
4759 posts, page by page
Link to page ... 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, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2019: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/2871_Mov ... hon-3.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat