Name: [002] Ian Ozsvald
Member: 101 months
Authored: 181 videos
Description: I am the co-founder of ShowMeDo (see, author of `The Screencasting Handbook <>`_ and the founder of the professional screencast production company `ProCasts <>`_: .. image:: ...

Python Beginners - Common Variables and Containers [ID:280]

a series of video-tutorials by Ian Ozsvald

Python has many datatypes, you'll recognise some from other languages and some may be new to you. In this long series I give 5-10 minute demonstrations of each of the major data-types and containers, along with some discussion of variables and printing.

The aim is to make you familiar with this fundamental part of Python - the usages should stick in your head for easy future reference.

Publishing Schedule - 2 per week from the end of June 2008, there are 14 episodes in total.

Video Tutorials

1. Overview (Variables and Containers)

This free overview will give you a taster for what's covered in this long series. In total there are 14 episodes covering all of the fundamental data-types and containers found in Python. These are the main objects that you'll be using and reading about, I show them along with typical usages. I also show a few 'gotchas' which might otherwise catch you out. This series covers: Variables are O [...]

2. Variables are Objects

All variables in Python are references to objects, more than one variable can reference the same object (which isn't true of some other languages). Since everything in Python is an object, everything has methods that govern its behaviour - again this isn't true in some languages. Here I give you a quick demo of the dynamic-typing and strong-typing nature of Python, along with the fact that you c [...]

3. Variable Scope

Python has scoping rules - not all variables are global. Depending on your programming background you may be familiar with the idea of scope, you may well not know Python's scoping rules. There is one particular 'gotcha' regarding global variables which I'll show - I've seen many beginners from other languages caught out by this. Links - Scope Pitfalls, global notes,'s rules for scop [...]

4. int and float

Here we look at the often-used int, long and float datatypes. Since everything in Python is an object, we look inside an int to see the methods that are exposed (including the magic double-underscore methods). I also show you how to print using C-like printing syntax. Python's int has a limited range, one nice feature is that it auto-promotes itself to the Long datatype if you need a bigger num [...]

5. decimal

The decimal type lets us store decimal data (like a float) without any precision problems (unlike a float!). This type is great for dealing with money or when you're concerned with fixed-precision accuracy. It defaults to 28 decimal places, you can set that to any limit. You probably won't use it very frequently but it is great to know that a non-lossy alternative to the float type exists. If [...]

6. str(ings)

Strings are another fundamental part of Python, you'll use them all the time. Python has another nice feature - there are several ways to represent strings so you can include various quotes (single, double) in a string without any need to use escape characters (you'll know all about this annoyance if you come from a C/Java background). [Note I refer to 'quoting' which is a less-used form of say [...]

7. unicode

You're bound to have heard of unicode, Python has unicode support built right into the core. If you're working with the web or internationalised applications then you'll need to know about unicode. Thankfully - it is very easy! Wikipedia can give you some background on unicode, many seasoned coders have ranted about the need for more unicode support in applications, e.g. this article by Joel Sp [...]

8. bool(eans)

You'll almost certainly know about Boolean logic (wikipedia example), Python's built-in bool datatype gives us all the Boolean logic that we'll need. If you've used C then you'll know that 0 represents False and 1 represents True, I show you how Python deals with alternate forms of True and False and give a simple example for truth-testing a user's input. Finally I show the Rules for Truth Testin [...]

9. list

Lists are a container type. Unlike in some languages you don't need to pre-declare them (this is true for all datatypes in Python) and you can manipulate them (e.g. changing their size) on the fly. Lists can hold multiple copies of the same item, they can hold different datatypes at the same time and they can be sorted very efficiently. I show you how to build up a list, sort it, reverse it and [...]

10. set

Sets (wikipedia) are used to hold a set of unique items - you can't have more than one of an item at once. Sets became standard datatype in Python 2.4 (before they were included but you had to import them). You can do set-like operations such as get the union or difference of two sets. One difference to a list is that you can't index into a set - nothing has a 'position' in a set so you can't a [...]

11. dict

The dictionary (dict) datatype is also know as an associative array. We use a dictionary to build up a key-value mapping. They are useful for very fast lookups (such as when caching) and for mapping general items together. Keys can be most normal datatypes but they have to be immutable - this means that you can't use a type such as a list as a key. Keys also have to be unique. I show you how t [...]

12. tuple

Tuples are quite similar to lists (as shown earlier). You can bundle several items together which are passed around under one variable, this can be handy. I'll show you how they work and discuss how they're similar to lists. You might find that you want to ignore them when you're first learning Python and instead focus on using lists, it'll be useful to you to know the syntax for tuples of cour [...]

13. None

None is a bit like NULL from C (wikipedia). It is a real object and can be passed around, only one will exist. It is very useful to indicate that you haven't yet assigned a value to a variable, e.g. if you're doing a computation and you want to show that you didn't get a useful result.

14. printing

Printing will change between Python 2.x (as shown here) and Python 3000 (the next major revision). The change is simple but will be one of the more visible changes you'll see. Here I give some behind-the-scenes info on how printing (and representation) works. Background: Formatting for print Print in Py3000 becomes a function Repr and str

Showmedo is a peer-produced video-tutorials and screencasts site for free and open-source software (FOSS)- with the exception of some club videos, the large majority are free to watch and download.

how to help » about » faq »

Educating the Open-source Community With Showmedo

Although as important as the software it supports, education and documentation are relatively neglected in the Open-source world. Coders love to code, and explaining how best to use or improve the software tends to be deferred or even sidelined.

At Showmedo we believe the community can play a vital role here and also say thanks for the tools and software that make our lives easier. If you have a piece of software you love or a programming langugage you are enthusiastic about, why not make a screencast showing others how to use it? All the stuff you wish you'd been told, the tips, tricks, insights that would have saved you time and frustration.

Screencasting is easier than you think, and we're happy to help you. You can emailus for advice or just use some of the how-to screencasts on the site. This screencasting learning-pathis a good place to start.

Kudos and Thanks for Ian

Learning Paths

This series lies on the following learning-paths. Learning-paths are a new initiative at Showmedo, to start structuring our content better. You can find out more here.



Showmedo's development is fairly rapid and bugs will inevitably creep in. If you have any problems please drop us a line using the contact address below. Likewise, any suggestions for improvements to the site are gratefully received.