• Last edited on Jun 15, 2017, 10:26:19 PM by 4014959 PM 2Ring

This is an unordered collection of issues members of the sopython community have found with the book Learn Python The Hard Way. We noticed a general trend that users using LPTHW post questions that don’t make a lot of sense both on SO and in chat. This is due to the structure and techniques used in the book. We recommend these tutorials instead. If you’d like to discuss this more, come chat!

  1. Repeatedly asks the reader to ensure that the reader uses Python 2, stating that Python 3 will not be in general use for a long time.
  2. Can have a quite condescending tone.
  3. Even the Python 2 version is out of date. Uses Python 2.6 in the examples.
  4. Exercise 3 on math does not talk about the rounding behaviour, about the from __future__ import division, or anything for that matter; details are left for the reader to find out. “Notice the math seems "wrong”? There are no fractions, only whole numbers. You need to use a “floating point” number, which is a number with a decimal point, as in 10.5, or 0.89, or even 3.0.“
  5. String formatting (Ex 6) just explains the % formatting
  6. Ex 10 tells about Unicode escapes, of course without telling what the Unicode is or how to do it in Python.
  7. Does not teach with for processing files
  8. Calls functions commands until teaching the word function. Likewise modules are features until they are called modules.
  9. First teaches the concept of command line and command line arguments and then (much later) proceeds to explain functions as some kind of miniscripts that take arguments akin to argv.
  10. Ex 23 again says: ‘Avoid any project that mentions "Python 3”. That’ll only confuse you.’
  11. Asks to memorize truth tables for Boolean ops, calls this “better than trying to understand it”
  12. Really backwards teaching order, files taught before any control structures.
  13. Ex 31 says this about testing whether a number falls into a range: “Use 0 < x < 10 or 1 <= x < 10, which is classic notation, or use x in range(1, 10).” And this is Python 2. Even in Python 3 the range is O(n) for floats and most probably would fail.
  14. Ex 37 - review - passingly mentions raise and yield in a table, that weren’t taught in previous exercises. Nor were the concepts of generators, iterators or even exceptions. .next() is used to get the next value from a generator.
  15. After teaching methods in 38, Ex 39 teaches dictionaries and… how to build a hash table class?!
  16. “Ex 40: Classes are like minimodules, objects are like mini-imports.”
  17. Ex 41 defines “composition” as “The concept that a class can be composed of other classes as parts, much like how a car has wheels.” and then immediately defines “attribute” as “A property classes have that are from composition and are usually variables.” This isn’t even wrong.
  18. Ex 43 teaches non-pythonic stuff, like picking a random item from a list with randint(0, len(x)-1) instead of suggesting random.choice
  19. Ex 45 says “method is a function”.
  20. Ex 46 teaches writing a package. Up until then the keyword arguments are not explained. A dictionary of arguments to setup is built, then applied with **
  21. Exceptions are finally taught in Ex 48, after the setup script. This is the first time a string is converted to an integer and exceptions handled appropriately.
  22. Uses recursion excessively, teaching users that chaining a series of functions to build a game is somehow good code flow (without ever talking about what this means in terms of the call stack).