Fairytale ending

31 Oct, 2015

Was there for the semi-final. Wish I'd been there for the final...

Tkinter mainloop issue on Raspberry Pi

26 Aug, 2015

Martin writes:

First of all thank you for writing "Python for Kids". It's a great book and offers "instant gratification". My 8-year-old is already hacking his way through the pages on his brand new Raspberry Pi.

He (we) ran into a bit of trouble when we started playing with Tkinter.

Your initial examples don't ever call mainloop() or update(). Turns out, on the Raspi, in IDLE, those examples don't work as expected - nothing appears on screen. Until you run mainloop() that is. raspberry pi screenshot

If you run a pure python3 interpreter inside a shell window, your examples work. [They will also not work on Windows inside a Python 2.7.10 IDLE.]

Could you throw any light on why things work without calling mainloop() on some setups but not on others?

Turns out that trying to reproduce your problem - without having a RPi to hand - was a lot more difficult than I expected. Even after getting Raspbian going with QEMU, I couldn't get a menu to display so that I could run IDLE (solution: create an empty file, and from the file's context menu you can then access the Terminal). However, when I ran IDLE, it only worked in "no subprocess mode" (see the first chapter of the book). If I run without specifying -n, I get the following error:

qemu error (small image)

Only after going through the above, did I remember that there was an issue with IDLE & tkinter on Python 3.2 (when running without -n). And sure enough, when running with 3.2 on my PC, I get the exact same problem (it doesn't occur with later versions of Python).

Best thing you can do, is to run IDLE with the -n flag - the turtle/tkinter code you run will be more stable as a consequence (and there's no need to call mainloop).

(PS. as for Python 2.7.x, many of the code samples won't work - the book is only intended to be used with Python 3.x)

Python 3.5 beta issue on Windows

21 Aug, 2015

Tony writes:

I have installed Python 3.5.0b3, and when I tried to make the shortcut, it looked very different from the book's examples and I did not get the toolbar with "File", "Edit", "Options", etc. on the top. Please tell me how to correctly complete the installation process. Thank you, and I hope to hear back.

I'm not sure exactly what error you're getting, but I would suggest that while learning programming, you should probably use the latest release version of Python, rather than the beta. So at time of writing, that's version 3.4.3.

I do know of one problem with 3.5, where you need to move the DLL found in directory c:\Python35\DLLs\Microsoft.VC140.CRT, up one level (to directory c:\Python35\DLLs), in order to get tkinter working -- which I guess could be part of your problem (as detailed here: https://bugs.python.org/issue24847).

So that's simply moving the file here:

microsoft.vc140.crt file - original location

to here:

microsoft.vc140.crt file - new location

Syntax error in myletter.py

14 Aug, 2015

I have recently bought your book, Python For Kids and I think it's great and easy to understand except for one small thing.

It tells me to put this into the Shell:

spaces = ' ' * 25
print('%s 12 Butts wynd' % spaces)
print('%s Twinklebottom heath') % spaces)
print('Dear Sir')

I do what it says, I click run module, but I get this error:
error in editor window
I'm new to this, so I probably made some extremely stupid mistake, and i'm sorry if this is the wrong place to ask.

When I enter your code, I get the same error. But once I click OK, in the editor window I see the following:
error in editor window
That red highlight, on the third line down, shows you on where the error has occurred - and hopefully gives an idea about what might have gone wrong. In this case, Python isn't expecting a bracket at the end, because you've got one earlier in the line: print('%s Twinklebottom heath') % spaces). If you remove that bracket (it should look like this print('%s Twinklebottom heath' % spaces) ), you'll find the program runs as expected.

Deprecated switch

12 Jul, 2015

Sandy S writes:

I just purchased 3 copies of "Python for Kids" so that my 2 sons and I can begin our quest! Anyway I hate to bug you with this but we just downloaded the latest version of the Python suite and the –n switch for IDLE startup has a message about "being deprecated since version 3.4". Is there another startup scheme that we should use instead? Also what do you recommend, in addition to the fine book, to enhance the learning process? My sons are middle-school age and very math/science savvy. I have a hardware engineering background but no programming to speak of.

The -n switch is deprecated, but not yet removed. So it still works fine with that switch for the moment. I did see some discussion about it on one of the Python mailing lists (forget which now) but I don’t think there was a conclusion about what happens in the future with something like IDLE and the use of tkinter (perhaps someone else reads this and lets me know - in which case, I'll post their message here). In any case, safe to use.

In terms of enhancing the learning process, I'd say once they've gone through the book (at least covered the basics of programming) picking a project is a good idea. Static learning is fine up to a point (even working through examples in the book), but what really cements the learning process is finding something you actually want to work on. It doesn't matter what sort of project, game or otherwise. As long as it's something your boys are interested in (also think about things like the raspberry pi and robotics and so on — since you've got a hardware background that'll be a useful crossover).

Hope that helps.