Exercises, examples and other material relating to training module Y300. This topic is presented on public courses Learning to program in Python
, Python Programming
, Intermediate Python
Python originated in 1988, and there are some elements dating back to the early days which
will hold back the ongoing development and use of the language 30 years later in today's very
different world. In Python 3, some of these time-expired features have been replaced by
more currently appropriate facilities, yet in a way that code may be moved across with as
little pain as possible. While much development work continues in Python 2, courses continue
to cover that version, but always with Python 3 in mind so that our delegates are writing code
that's good for the future too.
|Articles and tips on this subject||updated|
|2871||Moving from Python 2.6 to Python 3|
When 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 ...
|2778||Learning to program in Python 2 ... and / or in Python 3|
Yesterday - "Learning to Program in Python" - and I'm now teaching the day so that it's both Python 2 and Python 3 compatible. But it's really an intro day, and we'll vary how we go for the following 3 days of the course, majoring in an appropriate direction for our group - that's a luxury we have when ...
|2559||Moving the product forward - ours, and MySQL, Perl, PHP and Python too|
I have just posted a "steady as she goes" message, welcoming the new decade but reassuring our customers that we're carrying on offering very much the same high quality courses, and the same high quality hotel rooms. But things can't stand totally still - they would stagnate, courses would get out ...
|2285||Great new diagrams for our notes ... Python releases|
When training, I project onto a white wall ... and I draw onto the projected image, and add extra notes and diagrams around the side too - after all, the whole wall is a whiteboard. Some of the diagrams and slides that I'll come up with are new / unique for an individual course, and I end up photographing ...
|2277||Python classes / courses - what version do we train on?|
Usually, the release number of a programming language that's used on a 'first level' course doesn't make a big difference as the changes tend to be quite minor - after all, languages cannot change much for who would develop e piece of code using a syntax that was likely to go out of date? But that's ...
|1791||The road ahead - Python 3|
A couple of days ago, I mentioned Python 3 in general terms - and today I'm starting to flesh out the road ahead.
The print operator in Python was always a bit curious, with the trailing comma to signify "no new line" ... and that has been replaced by a print function, with named parameters ...
|1788||Python 2 to Python 3 / Python 3000 / Py3k|
There's a new release of Python on the horizon. Well - it's rather closer than the horizon, as there are beta test releases around, and a final production release is due within the month. It has been known as Python 3000 and Py3k along the way - but the release is numbered 3.0 and it's really known ...
|753||Python 3000 - the next generation|
There is no definite schedule for Python 3 (a.k.a. Python 3000 or Py3K) but a Python Enhancement Proposal (PEP) that details plans exists. There's a guiding principle to reduce duplication by removing old ways of doing things which will break version 2 compatibility. (Heard it before ... Perl 5 to Perl ...
Examples from our training material
|george|| Integer v float arithmetic|
|git_2.py|| Generator and xrange - Python 2|
|git_3.py|| Generator in Python 3, range replaces xrange|
|input_2.py|| inputs in Python 2|
|input_3.py|| Inputs in Python 3 - input replaces raw_input|
|john|| input and raw_input - Python 2 and Python 3|
|london.2|| Python 2.6 for conversion to Python 3|
|london.3|| Python 3 - converted from Python 2.6 example|
|print_2.py|| print in python 2|
|print_3.py|| print in Python 3 - print now a function|
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from http://www.training-notes.co.uk
Topics covered in this module
Why Python 3?
Print as a function.
Range and other iterators (map, etc).
nonlocal (compared to global).
New style classes.
Strings, bytes, unicode and string formatting.
A note on Decorators.
Versions 2.6 and 2.7 3.0 to 3.3 and 2to3
A Strategy for upgrade.
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.