Exercises, examples and other material relating to training module Y117. This topic is presented on public courses Learning to program in Python
, Python Programming
|Articles and tips on this subject||updated|
|4697||Month, Day, Year number to day of week and month names in Python - English and Swedish|
I had run a program (actually an answer to an exercise from our Lerning to program in Python course) which prints out a day and month number. And my group asked "how do I get the month by name?" and "What day of the week is that?"
Good questions ... and the answer in Python always starts ... "If you're ...
|4696||Programming with random numbers - yet re-using the same values for testing|
There are certain programming jobs where you want to simulate / model random occurrences - for example to shuffle a pack of cards, or (a manpower planning example from many years back) work out whether people leave an organisation duirng a year; it's no good working with percentages as you'll end up ...
|4452||Binary data handling - Python and Perl|
Handling binary data has become a somewhat rarer requirement over tiem, but that doensn't mean the need has gone away - and on last week's Python course, my delegates had a requirement to read data in this format.
First and foremost with binary data, you need to understand what you're looking to read ...
|4441||Reading command line parameters in Python|
The sys module in Python gives you access to operating system parameters such as the command line interface, via an ordered collection (I think a list, may be a tuple) called argv. Although many / most users these days don't use the command line directly, it's often used internally between programs in ...
|4086||Cacheing class for Python - using a local SQLite database as a key/value store|
Question from Tom: What did you have for lunch yesterday?
Answer: A Sandwich, a piece of cake and some fruit.
Question from Dick: What did you have for lunch yesterday?
Answer: A Sandwich, a piece of cake and some fruit.
Question from Harry: What did you have for lunch yesterday?
Answer: A Sandwich, ...
|4085||JSON from Python - first principles, easy example|
Here's a short example of how to pick up a JSON feed from a URL in Python. All the examples I came across looked very complicated, so I thought I would write one that's really straightforward:
Open a remote URL feed that provides a JSON object:
response = urllib2.urlopen('http://www.wellho.net/services/pix.json')
|2020||Learning Python - many new example programs|
I ran a public Python course earlier this week ... and (as I usually do!) wrote a number of short examples during the class to show the delegates not only how something is done, but also how the coding process works and how the particular answers are developed. I can't show you that process here on ...
|3479||Practical Extraction and Reporting - using Python and Extreme Programming|
"We seem to be getting a lot of signups from Germany" - so said my fellow administrator on the First Great Western Coffee Shop forum. At first glance is something of a surprise, as this forum is "provided by a First Great Western Customer, for First Great Western customers" and First Great Western run ...
|3465||How can I do an FTP transfer in Python?|
"If you think someone's probably done it before, they probably have .... and it's probably available to you" A good answer to many questions of the form "can I do xxxxx in Python?"
Question today "can I do an FTP transfer from Python"
Answer "Yes" [but I had a look around and discovered there was on ...
|3442||A demonstration of how many Python facilities work together|
Many of our demonstrations on the Well House Consultants site show individual features of a language - taken in isolaion to show you how they work. However, during a course we usually write further examples to show you how features work in combination to give a total result / solution to an application.
|2931||Syncronise - software, trains, and buses. Please!|
To get from my home to the Divisional Police HQ on another side of Melksham, I can take a five minute bus ride on the X72 or 272, change at the Market Place onto the 234 or X34, and ride for another five minutes. So for a meeting at 19:00, I can catch a bus just after 18:00 to be there in good time, ...
|2890||Dates and times in Python|
Python comes with a great variety of standard classes - including some very neat ones to handle dates and times. [Here] is a link to an example written on last week's Python course which took a couple of dates as strings, split them down and proceeded with date arithmetic. I always have to marvel at ...
|2506||Good example of recursion in Python - analyse an RSS feed|
I'm not keen on recursive code - code that calls itself. Very often, such code is elegant in a way, yet so 'clever' that it is hard to follow. There are, however, exceptions where I say "THAT is a good use of recursion". Once such is in the handling / parsing of RSS (Really Simple Syndication) feeds.
Examples from our training material
|avx|| Command Line Parameters|
|butter|| Regular Expressions|
|dates|| Date and Time - short example|
|fgrab|| FTP transfers |
|imgsize|| interpretting binary data|
|jones|| Random - really and replay|
|pyjson|| Using our JSON service from Python|
|pyjson_with_cache|| Using our JSON service from Python with cache|
|xz|| Day of week, month of year names and locales|
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from [here]
Topics covered in this module
Built in objects.
time, re, unittest etc.
The Vaults of Parnassus and the Cheeseshop.
Sourceforge and other sources.
wx, tkinter, qt.
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.