2bb7 Moving from Python 2.6 to Python 3
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
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 under
Y300 - Python 3 - What is new, what's changed and why
  [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)


5710
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?
4086 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 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., 2013: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • 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 Feb 23 12:39:13 2013 • BUILD SYSTEM: wizard
0