How I Learnt Python

2015-09-25

Judging from the people at PyCon UK that I spoke to, there was quite a lot of interest in learning Python. This is all good and to be expected. Not only are conferences a good place for the Python-curious, this conference had the Trans*Code, DjangoGirls, and the education track, all aimed at people who had never programmed in Python before.

ZX81 Basic Manual

ZX81 Basic Manual

Several times I got asked, “So, how did you learn Python”. How I learnt Python was that I learnt Sinclair BASIC from Steve Vickers’ ZX81 BASIC Programming when I was about 10 years old. A combination of a wobbly RAM pack and unreliable tape means you get good at typing programs in. Then I learnt a bit of Zilog Z80 machine code and wrote my own assemblers, and dabbled in FORTH. At sixth form I got an Atari ST, and I learnt Motorola 68000 assembler and started to dabble in C, Lisp (XLISP), more FORTH, and extensible text editors (MicroEMACS). At university I found C, more Lisps (Cambridge, Acorn, Common), more extensible text editors (the wonderfully charming and parochial ZED and E), scripting languages (WREN, lol), and a bit of ML. Towards the end of university I started to learn about Unix and ed, sed, vi, emacs, and awk. After that I got a job as a C programmer and learnt a lot more C and bit about the SPARC, UltraSPARC, MIPS, and ALPHA architectures. As well as more Unixes, and a bit about Windows NT, and Dylan. Java appeared on the scene (and I did write one small program in it). After that I learnt Lua. And then, eventually, Python. As you might imagine, at this point, learning Python is rather easy. There is almost nothing new in the language except for the indentation.

So my answer to the question is not very useful. Most people who ask the question want to know “how should they learn Python?”, and how I learnt Python is clearly not how they should learn Python. I’m not really sure I have a good answer, even though I’ve been involved in teaching it (at Software Carpentry, and with John Pinner at a PyCon). Python has an official tutorial, and I used that a long time ago and thought it was not bad. I’ve heard some fairly lukewarm responses from other beginners though. Software Carpentry is good, but not very frequent unless you want to travel a long way (and it is somewhat targeted at the scientific post-doc). I’ve never tried any of the MOOCs. I’ve seen someone go through many Python koans, but it didn’t seem to help them learn Python any faster than any other way. DjangoGirls had a very positive response at PyCon UK, and not only teaches Python from scratch but also Django, so you can make a useful website.

A buddy will help. A concrete goal will help, I love to quote Nardi:

“People are likely to be better at learning and using computer languages that closely match their interests”

Bonnie Nardi, “A Small Matter of Programming”

So if you like cycling write an app to calculate your favourite gear ratios, if you like climate science, try recreating the global historical temperature change.

If you haven’t learnt Python yet, how are you planning to? If you’re learning Python, how are you doing it? If you know Python, how did you learn it?

4 Responses to “How I Learnt Python”


  1. I guess I learnt Python by a similar but less professional track: VIC20 Basic, FORTRAN, Matlab and after that dabbling in a range of languages for fun, starting in Python around 1998.

    I think I only started writing approximately Pythonic code over the last couple of years whilst working at ScraperWiki (and pairing with more experienced programmers).

    My approach to learning languages has been to have a goal and achieve that goal in the new language. In C# it was writing an app for storing and showing my meter readings, in Matlab it was reproducing some analysis and visualisation of data, in Python it was scraping the contents of Physical Review E for the bits I wanted.


  2. My actual path to learning Python is quite similar to yours; the detail that forced me to take Python seriously was its increasing adoption at work.

    In general my approach to a new language is to find a tutorial, work through it quickly but actively playing with the examples, and then dive into whatever it was I really wanted to do with that language, dipping into a language reference as and when I need to. The last step, of applying the new knowledge to something, is crucial: after working through Roberto Ierusalimschy’s Lua book a few years ago I felt pretty confident about the language but in fact I never actually applied it to anything and by now I’d have trouble telling you even basic facts about the language syntax.

    Back to the work environment: to some extent we teach each other Python (and other languages we use). All our code goes through a peer review process (usually within small and consistent teams, although there are exceptions to this). I think that’s pretty valuable but it does have some limitations – it only works where a developer has already built up enough experience in a language to work on whatever real problem it is that we’re trying to solve that day; and it’s somewhat limited to our idea of what well-written code looks like, which I hope is a sensible one but is bound to differ from other people’s ideas, and no doubt misses out some language features.

  3. drj11 Says:

    These are really excellent comments, thanks! I’m pleased to see that you both say (I’m paraphrasing) that pairing (with “a buddy”) ups your game. I’ve definitely found this true. Even when both of us have been relatively inexperienced. One person knows something that the other doesn’t, and vice versa. When you’re both uncertain of how a language feature works you can explore and find out together.

  4. Gareth Rees Says:

    My story is similar to David’s. I first learned to program from Donald Alcock’s 1977 “Illustrating Basic”, which I read at the age of eight. I didn’t have a computer at the time, so I started out by writing programs on paper and running them with a pencil and rubber.

    I learned to program FORTRAN 77 on the Amdahl mainframe at the University of Leeds, AcornSoft LISP on the BBC micro, Borland Tubo Pascal and Microsoft QuickC in a summer job I took before university, and then in the course of a computer science degree I learned ML, Haskell, Prolog, Modula 2, Modula 3, and many others.

    After you’ve learned to program in a dozen programming languages, new ones are easy to pick up. Once you know about pointers (C), manual memory management (C), parametric polymorphism (ML), pattern matching (ML), lazy evaluation (Haskell), backtracking (Prolog), object orientation (Modula 3), template programming (ML, Modula 3), exceptions (Modula 3), and coroutines (Modula 2), there isn’t much that a programming language can provide that you haven’t seen before. You can easily become competent on a new language in a few days if you’re using it professionally.

    Nonetheless, each language has a niche where it’s particularly good, and Python stood out from when I first encountered it (in March 2000, Python 1.5.2) as a language which makes it possible to write programs very quickly (because of the interactive interpreter, the dynamic type system, the rich collection of built-in types, and the wide range of functionality in the standard library) while still writing programs that are easy to read and maintain (because of the simple syntax, the module system, and platform independence). In 2000, the only serious competitor was Perl (which was hopeless on the readability and maintainability attributes), but amazingly Python still maintains its lead in this niche fifteen years later, despite a flood of new languages.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: