Modified IDLE

23 Sep, 2018

Dean B writes:

I'm on page 137 of your book Python For Kids (chapter 10). I noticed a sentence at the top of the page, and have a question on it. It says "This won't work if you're using the modified version of IDLE that we set up in Chapter 1." I didn't remember seeing anything in chapter 1 on a modified version of IDLE. I looked back through chapter 1, but still don't see anything on the matter.

Would you please tell me what page that is on? I'm more curious than anything. I was frustrated with the "New File" window so I did a search and found IDLEX extensions and installed that. It works quite well for me. I would like to know though how your modified version works.

I'm new to programming and after searching for a good programming language to start with I chose Python, and after looking through a lot of books I chose your book "Python For Kids". I’m a senior citizen and have found this book to be a great introduction to Python. Certainly not just for kids as long as the adults are okay with the kid like context. Works for me, and thanks for such a good book.

Apologies for the confusion there -- this was a miss when we updated the book for later versions of Python 3. When Python for Kids was released in 2013 (end of 2012), you needed to make a minor modification to the shortcut used for starting up IDLE, to turn off "subprocess mode". Without going into too much detail about what that is, effectively if you ran IDLE with subprocess mode on, some of the graphical examples (tkinter, etc) would cause the Shell to hang. This was fixed in a later version of the IDLE runtime, and I removed those instructions from the first chapter on installation -- but completely missed the reference on page 137. Thanks very much for letting me know and I've updated the errata here.


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.


Error opening IDLE on Mac OS X 10.6

10 Jan, 2015

Lucas writes (excerpted):

When I try to open IDLE as instructed on page 11 I get an error message.

Error dialog

Any suggestions?

It depends on which version of Python you're running, but if you've installed the latest (3.4.2), then instead of putting the following in Automator:

open -a "/Applications/Python 3.4/IDLE.app" --args -n

Try putting this instead:

/Library/Frameworks/Python.framework/Versions/3.4/bin/idle3.4 -n

The reason the text in the book doesn't work is a difference between Automator in versions of OS X prior to 10.7 (I believe 10.7, anyway) and later versions of the operating system.


Multiple statements found

08 Sep, 2014

Arijjan V writes (excerpted):

When I enter code into the compiler I continue to get multiple statement error messages. Even if I copy the code from the book.

I use Idle 34 on windows professional 7. This is what I typed into the Idle Shell.

found_coins = 20 magic_coins = 70 stolen_coins = 3 coins = found_coins for week in range(1, 53):     coins = coins + magic_coins - stolen_coins     print('Week %s = %s' % (week, coins)) **Click Enter** SyntaxError: multiple statements found while compiling a single statement

I searched online but it's not an indent error. I'd appreciate any help.

To be honest, I'm not quite sure how you managed to get that error when typing the code into IDLE - the only way I can get it to happen, is if I copy-and-paste directly into the Shell:

Multiple statements showing error

The reason being is that you can only copy-and-paste line-by-line into the Shell window (a quirk of the way it works). What you should actually be entering looks like this:

Multiple statements without error

If you want to paste in a large chunk of code, then click File, then New File, then paste the code, and save the file before trying to run it:

Multiple statements in new file

If you can reproduce the problem when typing in the code, send a screenshot (take it after entering a few lines) -- I'd be interested to see if it's obvious from the screenshot what the cause is...


Python 3.4 Shell

15 Jun, 2014

Kirk K writes:

On page 12 it says File>New Window but I cannot find it on our Windows version 3.4.1. Please advise.

It looks like, as of Python 3.4, they've changed the menu, so File->New Window has become File->New File (which makes the Shell consistent with other text editors, at least). It still has the same behaviour though - opening a new window for typing in your Python code.


What is -n for

27 Aug, 2013

John writes:

Quick question regarding the -n used in the shortcut for IDLE. I realize that it starts IDLE with no subprocesses, but what does that mean and why do we want to do it?

There's precious little on the net describing what the -n switch does. From the IDLE documentation:

If IDLE is started with the -n command line switch it will run in a single process and will not create the subprocess which runs the RPC Python execution server. This can be useful if Python cannot create the subprocess or the RPC socket interface on your platform. However, in this mode user code is not isolated from IDLE itself. Also, the environment is not restarted when Run/Run Module (F5) is selected. If your code has been modified, you must reload() the affected modules and re-import any specific items (e.g. from foo import baz) if the changes are to take effect. For these reasons, it is preferable to run IDLE with the default subprocess if at all possible.

Which, I admit, doesn't help a huge amount...

For the purposes of Python for Kids however, all you really need to know is that certain graphical libraries (such as turtle and, I seem to recall, tkinter) will exhibit weird behaviour (such as locking up/hanging) if you don't run IDLE using the -n switch.