Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
Writing Python 2 such that Python 3 is easy

If you're writing code in Python 2 (2.7.x) ... and want an easy port to Python 3

a) Use the format method in all your prints - example ([here]

b) Use // if you're dividing and want an integer result

c) Wrap standard functions that you need to return a list in list( through )

d) used sorted in preference to sort

e) Inherit lowest base classes from object even though not needed in Python 3

f) test the code in Python 3 occasionally ... at a unit test level even if not the whole application!


(written 2016-11-06)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
Z300 - Politics and Religion
  [4737] Why you should vote for Lisa in Melksham Central - (2017-05-01)
  [4735] Revisiting - should I stand for Melksham Without Parish Council in May? - (2017-02-24)
  [4734] Thoughts on the new Blackmore Ward of Melksham Without Parish - (2017-02-22)
  [4729] The oldest part of Los Angeles - (2016-11-23)
  [4720] Celebrating our diversity rather than discriminating for it - (2016-11-02)
  [4625] Where does Wiltshire bus subsidy money come from? - (2016-01-19)
  [4614] PC Plod - alive and scaremongering in Wiltshire? - (2016-01-04)
  [4597] Not standing as your local councillor - (2015-12-18)
  [4548] Melksham - two small townships, or one big one? - (2015-10-22)
  [4489] Election results - what if we had a party list system? - (2015-05-08)
  [4485] Misusing statistics? - the seedy side of election campaigning - (2015-05-04)
  [4476] Upcoming election - Chippenham Constituency - the major candidates compared - (2015-04-29)
  [4354] Wiltshire Police - assuming someone is guilty just on the say-so of a member of the public? - (2014-12-16)
  [4343] Politics and the railway the connects Wiltshire - (2014-12-06)
  [4286] Reaction in Radstock to new First bus prices - (2014-07-12)
  [4275] Eurpoean Elections, and other elections ahead. Some thoughts on campaigns and policies - (2014-05-08)
  [4223] Democracy - alive and well with the beauty pagent starting up again - (2013-12-16)
  [4079] Melksham Area - Unitary Council results, May 2013 - (2013-05-04)
  [3921] On rememberance, on war, and on preventing the war cycle - (2012-11-11)
  [3905] How should we choose our Wiltshire Police and Crime Commissioner? - (2012-10-27)
  [3845] Good cause giving - getting the charity beggars off the street - (2012-08-21)
  [3806] 2011 Census results - initial figures for Wiltshire. - (2012-07-17)
  [3676] Rising prices, changing habits and society - (2012-03-31)
  [3592] Are we one man, one vote? No, and we never have been. - (2012-01-26)
  [3438] Melksham to become a part of Trowbridge? - (2011-09-13)
  [3325] The Olympic Torch, and Melksham House - (2011-06-14)
  [3323] Is Melksham town centre dying? - (2011-06-11)
  [3313] What does our MP do on a Bank Holiday? - (2011-05-30)
  [3264] Alternative Vote (AV) - explaining and an example - (2011-04-25)
  [3051] Positively reforming the system - could it be done? - (2010-11-14)
  [2971] Should the public sector compete with businesses? and other deep questions - (2010-09-26)
  [2948] Melksham shamefully makes the national headlines - (2010-09-07)
  [2870] Old prices - what would the equivalent price have been in 1966? - (2010-07-14)
  [2864] Changing with weather and seasons - (2010-07-10)
  [2856] Two sides of the coin - (2010-07-06)
  [2824] A pint of Black Rat, and a lazy barman - (2010-06-25)
  [2792] Should Government compete with private industry? - (2010-06-03)
  [2757] Bodicea, Lincoln, and our new MP - (2010-05-09)
  [2752] Voting day - UK General Election - (2010-05-06)
  [2740] Melksham Hustings at George Ward School - (2010-04-26)
  [2712] A more informed decision than ever before - (2010-04-08)
  [2689] Can my dog eat potatoes? Doggie Dietary Research, and political sleaze! - (2010-03-23)
  [2640] How is your tax pound spent? - (2010-02-18)
  [2353] All change - Wiltshire Parliamentary - (2009-08-13)
  [2288] Wiltshire Community Area Partnerships - (2009-07-15)
  [2279] Understanding the new local government structure in Wiltshire - (2009-07-11)
  [2270] Wiltshire - a chance to improve life for everybody - (2009-07-05)
  [2257] Ramblings on church and state linkage in Melksham - (2009-06-25)
  [2206] Spot the odd one out - (2009-05-29)
  [2178] Melksham Candidates for Wiltshire Unitary Election - (2009-05-12)
  [2075] Supporting Parkinsons and Trains - (2009-03-11)
  [2028] Things people say on the phone - (2009-02-06)
  [2012] The Wiltshire Police - (2009-01-29)
  [1987] One Cheer for Local Democracy - Asda in Melksham - (2009-01-11)
  [1882] Wiltshire Council says - part 2 - (2008-11-14)
  [1881] Wiltshire Council says - part 1 - (2008-11-13)
  [1872] Barack Obama wins US Predidency - (2008-11-05)
  [1769] July child ponders on August children - (2008-08-23)
  [1729] Back from the future - (2008-07-30)
  [1579] Rome, and the faith of Rome - (2008-03-17)
  [1573] Budget tax increases hit vehicle market - (2008-03-14)
  [1526] Carers at work - court case changes - (2008-02-01)
  [1428] Travel Across Wiltshire - the game - (2007-11-11)
  [1386] New software product for warmblooded programmers - (2007-10-10)
  [1350] FSB (Federation of Small Businesses) Western Region - (2007-09-13)
  [1260] An inspirational business talk from one of our prospective MPs - (2007-07-06)
  [1247] An afternoon at a public enquiry - (2007-06-27)
  [1175] Local elections - choosing who to vote for - (2007-05-03)
  [1135] Government pressure on me to shut up after I make the papers - (2007-04-05)
  [1109] False imprisonment - a contrast from the news - (2007-03-15)
  [1060] What a relief from the tax office. - (2007-02-01)
  [1003] Room at the Inn, Guy at the station - (2006-12-21)
  [967] Realistic on line shoot'em up - (2006-12-05)
  [875] Wilfred Emmanuel-Jones - (2006-09-22)
  [780] Separation and Integration - (2006-06-27)
  [750] Almost everyone loses - (2006-06-07)
  [696] Is than an uphill or downhill task? - (2006-04-23)
  [682] Iran has enriched uranium ... - (2006-04-12)
  [674] Wiltshire to get an extra MP - (2006-04-07)
  [671] Both ends of the animal - (2006-04-05)
  [607] On being British - (2006-02-14)
  [602] MP face to face - (2006-02-12)
  [539] rich and famous - (2005-12-23)
  [505] Would you steal ... petrol? ... a training course? - (2005-11-26)
  [469] Yesterday was Kiss and Ride - (2005-10-19)
  [415] Campaign Drift and efficiency. - (2005-08-15)
  [384] Managing conflict and disappointment - (2005-07-20)
  [377] A Strengthened City - (2005-07-14)
  [335] Sad priorities - (2005-06-03)
  [326] UK Tax payment totals and where the money is spent - (2005-05-27)
  [313] Making bona fide international marriages more difficult - (2005-05-16)
  [301] General Election day, UK - (2005-05-05)
  [289] MP for Devizes, Wiltshire - (2005-04-23)
  [280] Spotted - the local MP - (2005-04-15)
  [257] Politics gets nasty. Must be an election coming up. - (2005-03-25)
  [216] Cheap purchase - votes paid for with selfish promises - (2005-02-15)


Back to
From and Import in Python - where is the module loaded from?
Previous and next
or
Horse's mouth home
Forward to
TransWilts Partner Update for Melksham Area Board
Some other Articles
Visiting Los Alamitos Bay Yacht Club
Learning from travelling further afield
TransWilts Partner Update for Melksham Area Board
Writing Python 2 such that Python 3 is easy
From and Import in Python - where is the module loaded from?
Conditional operators in Python
Embedding more complex code into a named block
When to check an object type - Python isinstance example
4734 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: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4725_Wri ... -easy.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat