Jump to content
6 replies to this topic
Posted 27 May 2011 - 06:00 AM
I am having a syntax error with the code from pg 31:
for each_item in the_list:
if isinstance(each_item, list):
I get file "(stdin)", line 1 and the parser is under the the "m" in item in last line
Posted 27 May 2011 - 06:06 AM
the post is not showng the indents I placed in the code
Posted 27 May 2011 - 05:20 PM
I have attached a screenshot of the IDLE. I am probably missing something simple, but I have retyped and checked it at least a couple of dozen times.
Posted 28 May 2011 - 08:44 AM
Sorry you are having so much trouble. Two things to check. Be sure you are using Python 3, not 2. Also, be very, very careful with tabs in the shell (as it gets very fussy). Maybe try opening an edit window in IDLE, typing the code in there, and then running the code by pressing F5?
Posted 30 May 2011 - 11:50 AM
I have just typed the code in IDLE window and I still get a syntax error. Can you tell me how the automatic indent is supposed to work in the IDLE. I dont get any auto indent at all,so I indented it manually.
Posted 30 May 2011 - 09:24 PM
As Paul said, IDLE is really picky if you have mixed tabs and spaces in your code. I had to fight IDLE a lot while I was going through the book.
A menu command you might want to try: If you enter your code in a separate window, there is a Format menu. Under the Format menu is an option to Untabify Region Alt+6. Select all your code, then select this menu option (or press Alt 6). That should get rid of any tabs in your code.
Posted 31 May 2011 - 02:15 PM
Thanks . This was helpful advice. Generally, when I have prblems it is due to some error in typing code. However, I did the HF C# book and found that it is also important to be aware of errata. I just spent 2 hours on the distribution code in Chapter 2 and finally looked up errata to find out that "sudo" is not needed in Windows environment.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users