Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
A reminder of the key issues to consider in moving from Python 2 to Python 3

1. New style classes take on the old style class format
  But does it matter if you explicity inherit in Python 3??

2. print moves from being a keyword to a function
  Single value tuple as parameter will work in both cases
  You may also do a sys.stdout.write

3. integer division using "/" returns a float
  Use // if you need the whole number back

4. raw_input becomes input
  Thank goodness ;-)

5. sort's callback changes to a "key =" type using a single parametered lambda
  But remember you have things like sorted backported to 2.7

6. Text strings dáfaut to unicode in Python 3

7. You need all your modules and dependencies sorted out for Python 3 before you switch to that

8. You can't use new Python 3 stuff in Python 2 unless it's been backportd

In most cases, it's practical to write code that works with both Python2 and Python 3. However, if you must write something a bit different, you can use:
  if sys.version_info < (3,0):
and you do need to remember that even if you do this, the syntax must be compatible with both the Python 2 and Python 3 compilers!
(written 2016-10-30)

 
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
  [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)
  [2871] Moving from Python 2.6 to Python 3 - (2010-07-14)
  [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)

Y199 - Python - Fast Start
  [4713] Equality (in Python) - (2016-10-30)
  [4709] Some gems from Intermediate Python - (2016-10-30)
  [4707] Some gems from an introduction to Python - (2016-10-29)
  [3519] Python - current versions and implementations (CPython, Jython, IronPython etc) - (2011-11-13)
  [2017] Python - a truly dynamic language - (2009-01-30)

Y050 - Python - General
  [4656] Identifying the first and last records in a sequence - (2016-02-26)
  [4558] Well House Consultants - Python courses / what's special. - (2015-10-28)
  [4434] Public training courses - upcoming dates - (2015-02-21)
  [4408] Additional Python courses added to our schedule - (2015-01-29)
  [4295] A longer Python ... training course - (2014-09-16)
  [4236] Using Python to analyse last years forum logs. Good coding practise discussion. - (2014-01-01)
  [3935] Whether you have programmed before or not, we can teach you Python - (2012-11-25)
  [3911] How well do you know Perl and / or Python? - (2012-11-04)
  [3903] Python Programming class for delegates who have already self-taught the basics - (2012-10-25)
  [3902] Shell - Grep - Sed - Awk - Perl - Python - which to use when? - (2012-10-22)
  [3816] Want to escape the Olympics? Learn to program in the countryside! - (2012-07-23)
  [3798] When you should use Object Orientation even in a short program - Python example - (2012-07-06)
  [3489] Python courses and Private courses - gently updating our product to keep it ahead of the game - (2011-10-20)
  [3463] Busy weekend of contrasts. - (2011-10-03)
  [3076] Python through the Snow - (2010-12-01)
  [2822] Python training courses for use with ESRI ArcMap software - (2010-06-23)
  [2504] Learning to program in ... - (2009-11-15)
  [2394] Two days of demonstration scripts in Python - (2009-09-05)
  [2367] Learning to program - how to jump the first hurdles - (2009-08-20)
  [2227] Learning PHP, Ruby, Lua and Python - upcoming courses - (2009-06-11)
  [2020] Learning Python - many new example programs - (2009-01-31)
  [16] Python training - (2004-08-16)

Y102 - Python - Fundamentals
  [4442] Mutable v Immuatble objects in Python, and the implication - (2015-02-24)
  [4324] Learning to program - variables and constants - (2014-11-22)
  [3917] BODMAS - the order a computer evaluates arithmetic expressions - (2012-11-09)
  [3886] Formatting output - why we need to, and first Python example - (2012-10-09)
  [3551] Some terms used in programming (Biased towards Python) - (2011-12-12)
  [3278] Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java. - (2011-05-05)
  [3181] Beware - a=a+b and a+=b are different - Python - (2011-02-23)
  [3083] Python - fresh examples from recent courses - (2010-12-11)
  [2442] Variable storage - Perl, Tcl and Python compared - (2009-10-08)
  [2368] Python - fresh examples of all the fundamentals - (2009-08-20)
  [1878] Pascals Triangle in Python and Java - (2008-11-10)
  [1461] Python - input v raw input - (2007-12-06)
  [1448] Question on division (Java) - Also Perl, PHP, Python ... - (2007-11-28)
  [1430] Integer v float - Python - (2007-11-12)
  [956] Python security - trouble with input - (2006-11-30)
  [748] Getting rid of variables after you have finished with them - (2006-06-06)
  [633] Copying a reference, or cloning - (2006-03-05)
  [328] Making programs easy for any user to start - (2005-05-29)


Back to
Convering from Python 2 to Python 3 - an update, and the 2to3 utility
Previous and next
or
Horse's mouth home
Forward to
Equality (in Python)
Some other Articles
Profiling your Python program
Well House Manor - Still five out of five!
The technical article feed continues - personal updates more proactive on Facebook now!
A reminder of the key issues to consider in moving from Python 2 to Python 3
Searching a Json or XML structure for a specific key / value pair in Python
Scons - a build system in Python - building hello world
4724 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 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., 2017: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4712_A-r ... hon-3.html • PAGE BUILT: Sat Jun 11 12:16:26 2016 • BUILD SYSTEM: WomanWithCat