Scratch or Python?

23 Jun, 2013

Marvin writes:

I have a 10 year old son who is interested in programming. He really loves playing games so I thought he should learn how they are created. I am a bit confused on which language to have him start.

My question is should he start with Scratch (and for how long?) or should I start him with the Python language (with your book)? I've also heard about Ruby for Kids. Which is the easier path for him to start.?

I will greatly appreciate you thoughts on how he should get started?

Well, by all means, my book... ツ

But to be entirely honest, it's a difficult question to answer. Some kids will find the visual nature of Scratch attractive. And it may be a natural progression to go from something like Scratch to a more traditional programming language (not something I have a lot of experience with, given I started with a traditional programming language when I was a kid). But, if he has a modicum of technical ability, and an interest in how games are really created, then learning a traditional programming language may be the better path.

Either way, I don't think it will do any harm to start with Scratch, and progress to Python if he finds Scratch a little mundane - or vice versa, start with Python and go back to Scratch if he finds Python too advanced. However, in terms of Ruby, I can't really comment, as it's not a language I have much experience with.

Not sure that particularly helps, but good luck anyway.


Problems installing Python

05 Jun, 2013

Chana writes:

Python does not install on my computer, and I'm not sure why.

Windows 7 Home Premium 64-bit operating system

Everything works fine until you get to the part that says "Please wait while the installer installs python..." After about half an hour, a little window pops up that says that the installer is no longer responding.

According to this page... http://superuser.com/questions/168561/python-wont-install-on-windows-7... you should try disabling UAC. I'm not a home Windows user, but a quick google found this: http://www.howtogeek.com/howto/windows-vista/disable-user-account-control-uac-the-easy-way-on-windows-vista/. Hopefully that fixes the problem.


O'Reilly Media Discounts

04 Jun, 2013

Apparently Python for Kids is featured in O'Reilly Media's "Learn to Program ebooks" promotion (save 50% on introductory programming ebooks). More details can be found here.


Lander Solution Posted

26 May, 2013

A partial solution to the Lunar Lander 'Programming Puzzle' has just been posted.


One versus two underscores

19 May, 2013

Omer writes:

I am currently on Chapter 13 and I have come across a problem that I cannot seem to figure out. I am in the section 'Creating the Ball Class'. I wrote the code the way that you have described in the book, and I am getting the following error:

Traceback (most recent call last): File "C:/Users/Omer/Desktop/Master Functions/PaddleBall.py", line 22, in <module> ball = Ball(canvas, 'red') TypeError: object.__new__() takes no parameters

However, when I copied the code from your website, it worked perfectly. I put my code and your code side by side and I cannot seem to figure out where the mistake is. Can you help me figure this out.

It's easy to miss something when you're manually comparing two files. The best way to do this sort of thing is to use a diff tool. You're using Windows, so something like winmerge would do the trick. In any case, when I diff the files you sent using the command line diff tool, I see the following difference:

14c14
<     def _init_(self, canvas, color):
---
>     def __init__(self, canvas, color):

So in your code you've got a single underscore on either side of init - which explains the error you're getting. Because you haven't defined the __init__ function correctly, Python assumes a default with no parameters. Fix that, and the code should work as expected. Good luck!

Addendum (for anyone searching for similar errors): on Windows, you'll probably get a message like "TypeError: Ball() takes no arguments", but ultimately the cause is exactly the same.


Problems with files

18 May, 2013

Evan writes:

I have a Windows 8 PC, and have installed Python 3.3 onto it, and worked my way up to the last part of chapter 9 in your book with no major problems. But now I am stuck in the last part of chapter 9. The first time I tried to save a notepad txt file to the C: location, access was denied, because the user account I was using was not the dominant user account. I fixed this by running the notepad as the administrator, and was able to save the txt file to the C: location. Opening and printing the contents of the txt file worked fine after that. My next problem (and still is a problem) was writing to the text file. The first error message said access was denied. I fixed this also by going to the administrator's user account and allowed the user settings I was working on to have almost complete control over all the C: location. Now when I try to write to the txt file, I get a different error: "OSError: [Errno 22] Invalid argument: 'c:\myfile.txt'. Please help me!

Hi Evan. The final error you're getting is generally caused by an invalid filename (for example, if you had two colons rather than one) - but I don't see that problem in the example you sent. So I'm not quite sure what's gone wrong there.

In terms of the example in the book, I've added a new entry in the errata (see the section Page 123). The directions should instead tell you to save the file to your user directory - something like: c:\\Users\\Evan - rather than to c:\. Check the errata and hopefully that should work for you.


Tkinter colorchooser problems

01 May, 2013

Michal writes:

My son has found a problem. It is regarding:

from tkinter import *
colorchooser.askcolor()

It is not working and I cannot help him. On the python shell he gets an error:

Traceback (most recent call last):
File "colorrect.py", line 2, in <module>
colorchooser.askcolor()
NameError: name 'colorchooser' is not defined

Could you help please.

This is an odd one. If I try the code in the Shell, the color chooser is available as expected:

colorchooser1

But if I try the same code in the command-line console, I get a similar error:

colorchooser2

The only way I can reproduce the problem in the Shell is when I don't run it in "No Subprocess" mode - that's if you don't follow the installation instructions, in Chapter 1 of the book, and just run the Shell/IDLE as it was installed (without modifying the shortcut):

colorchooser3

You can get around this, by directly importing the colorchooser module like so:

>>> import tkinter.colorchooser
>>> tkinter.colorchooser.askcolor()

But you'll probably hit problems if you try to call the askcolor function (the second line in that snippet of code above).

All of which is rather messy and confusing. My suggestion would be to make sure you see the "No Subprocess" message when you run IDLE, and if not, revisit Chapter 1. If you do see the message on startup, and still get the error (which I haven't managed to do, but I'm guessing might be possible), try the sample code above, and see if that works for you. Good luck!

More information updated July 2020 here.


Good luck

24 Apr, 2013

To the (I assume) wannabe-hackers who, according to my web server logs, are trying to access various combinations of wp-admin, wp-login and other types of login page... good luck with that! ツ


Python on the Web?

17 Apr, 2013

Dean writes:

I'm 13, I live in the US, and I just finished reading your excellent book "Python for Kids". After I finished the book I had two questions. First I was curious if it is possible to put a python game on a website to play? The other question I had was what was the hardest project you have ever worked on, how long did it take you, and what language was it in?

There are a few implementations of Python that will work inside the browser, but as far as I know they don't support all of Python's features (such as the tkinter module, or PyGame, for example). So it would be rather difficult to write a game that could be played on a website (in my opinion). If that's something you want to do, you'd be better off learning Javascript (the standard programming language used in all browsers). If you google for "javascript and html5 games development", you'll find a lot of information out there. Luckily, once you've learned one programming language, it's a lot easier to learn the next.

In terms of hardest project, that's a difficult question to answer. I've worked on projects which were hard because the amount of code in the application was huge, and because there were a lot of "moving parts" - lots of communication between different systems. In terms of complicated systems, I recall one project (which I spent about 18 months on with a team of 8 or 9 people) where I had to write the code for very complicated graphical reports -- that was hard because I had to remember mathematics I learned years before (the programming language in that case was Java and some Python as well).

Hope that helps.


Solution 6

14 Apr, 2013

The solution to programming puzzle #6 has just been posted.