SWFK for Python 3

Wednesday, 10 December, 2008

I’ve updated “Snake Wrangling for Kids” to be compatible with Python 3. This mainly consisted of replacing “print blah” with “print(blah)”, fixing problems with range, and otherwise tidying up a few mistakes, errors, etc.

I’ve also taken the opportunity to replace the existing green-coloured code samples, with a plain black, larger font — apparently the green version didn’t print that well. Particularly on older lasers.

Both the new version, and the previous version for Python 2 are now available from the SWFK page.

4 Responses to “SWFK for Python 3”

  1. [...] Vote SWFK for Python 3 [...]

  2. David says:

    Great book.

    The one change I would make would be to use an initial forward quote when you are giving the Python syntax for a string literal in the text as opposed to using an initial open quote (backquote) when you are quoting text:
    p34 “print(`Hello’)” -> “print(‘Hello’)”, since the quotes here refer to Python syntax rather than quoting text
    Similarly
    p34 “print(`Goodbye’)”
    p38 “between 10 and `10′”
    p38 “set to `10′ (note the quotes)”
    and possibly others
    The last mentioned one is especially important since you explicitly ask the reader to look at the quotes.

    Note in contrast that p35 “you should see `Hello’” is perfectly fine since the quote marks are quoting what is printed, not referring to Python syntax for strings

  3. jrbriggs says:

    Page 34 is a mistake. I shouldn’t have changed that to the function print(). I’m changing the other quotes accordingly. Thanks for pointing those out.

  4. Andy says:

    Hi There,

    Good work!

    Reading your installation instructions for py3k I can see three things that would have tripped me up following your installation instructions on my ( Tiger ) mac….

    1/ I think safari default download location is ~/Desktop, your steps assume ~/Downloads
    2/ DEPLOYMENT_TARGET=10.5 isn’t necessary a given ( Lots of 10.4, 10.3 etc. macs still in circulation ).
    3/ It may have changed for newer macs but I needed to explicitly install the dev tools, so ./configure would likely fail with error message not likely to be helpful to newbies.
    4/ ( TENTATIVE-untested) Is it safe to assume tkinter/tk is available for the turtle graphics examples?

    Debatable how best to resolve, but if it were me, I would maybe more strongly recommend using one of the older editions, and leave the compilation instructions as ‘for the brave’ or something. A lot of people are just going to stop altogether if they hit a problem while correctly following a a list of step-by-step instructions.

    Cheers,

    A.

  5. jrbriggs says:

    Thanks for the info… I’m hoping an installer for python 3 will be released shortly.

Leave a Reply