Tag Archives: Python

Tech Book: Effective Python, Brett Slatkin

I’ve been learning Python for a few months and am starting to use it at work, so I thought it was about time to read a book about Python. This book has been excellent. No only does it follow format of the time-honoured ‘Effective’ series pioneered by Scott Meyers, it also features practical, useful code examples. In particular, his JsonMixin class was immediately relevant to some work I’ve been doing to generically serialise to/from JSON documents – see Item 26 “Use Multiple Inheritance Only for Mix-In Utility Classes”.

The author has also taken the time to record hours of video lessons for Safari Online subscribers, so you can view additional material as he works through the items in the book.

Leave a comment

Filed under Python, Tech Book

How to learn Python III – Google Python Class

I recently found a link to the Google Python Class in my inbox and have been very impressed with it. Whilst I’ve already explored some Python learning materials, this class benefits from a combination of lecture videos, online resources and exercises (with solutions) that’s hard to beat.

I’ll repeat the index here for (my!) ease of reference:

  1. Introduction
  2. Strings
  3. Lists
  4. Sorting
  5. Dicts and Files
  6. Regular Expressions
  7. Utilities

The exercises in particular show the power of Python, leveraging the commands, os, re and urllib modules to great effect.

The presenter Nick Parlante is enthusiastic and expertly demonstrates how to work incrementally with Python, on top of doing a great job of teaching the syntax.

nickparlante

Leave a comment

Filed under Python

How to Learn Python II

python-logoI recently wrote about starting to learn Python using HackerRank exercises. I’ve also been recommended Paul Ross’s training exercises. I think you need to have covered some introduction to the language first of all, but these exercises are accompanied by useful tips and solutions, which is very helpful. I also downloaded PyTest as per the recommendations – it’s easy to install (just download the zip from github and run “python setup.py install” as an admin) and provides neat unit testing for Python applications.

2 Comments

Filed under Programming, Python

How to learn Python

Having learnt enough Swift to write a neat watch face app for Apple Watch this summer, I thought I’d turn my attention to learning some Python.

Firstly, I wanted a way to edit Python commands in a decent editor and run them. It appears that Xcode doesn’t support this out of the box, but this handy StackOverflow question gives the details on how to set it up.

Secondly, I wanted a series of challenges/tutorials to walk through the basic syntax of Python. HackerRank.com is very good for this sort of thing and has a decent set of exercises to work through.

My first bug was very revealing about the differences between Python and strongly-typed languages like F# and C++:

N = int(raw_input().strip())
if (n > 10):
    print( "big" )
elif ( N < 0 ):
    print( "negative" )
else:
    print( "normal" )

The Python Interpreter doesn’t give an error because of the typo “n > 10” instead of “N > 10” – it just carries on regardless!

Finally, Python Software Foundation seems like a good reference site with lots of examples.

See also the next post in this series.

3 Comments

Filed under Programming, Python