O'Reilly Forums: Chapter 4, Page 112: Sharpen Your Pencil Solution - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Chapter 4, Page 112: Sharpen Your Pencil Solution

#1 User is offline   Snap E Tom 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 27-December 12

Posted 27 December 2012 - 12:19 PM

Hi, all. I'm having an issue with the example using IDLE.

Posted Image

As soon as I start typing on the new try block, I get that syntax error. If I put this code into a separate *.py and feed it into python via the command line:

python3 < chapter4.py

It works fine. Same indentation, same code. Is there something wrong I'm doing with IDLE?
0

#2 User is offline   paulbarry 

  • Advanced Member
  • PipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 257
  • Joined: 20-August 09

Posted 28 December 2012 - 06:03 AM

Hi Tom.

I'm not sure what IDLE is doing here, but... my general rule-of-thumb is that when my code gets longer than a few lines I stop entering it into IDLE's shell prompt and either (1) open my favourite editor or (2) use IDLE's edit window. Your code is obviously OK as it works at the command-line. BTW: you don't need the "<" on the command-line, the python command will open the named file automatically, so "python3 chapter4.py" should work fine.

Sorry I can't be of more help, but at this point in the book you have probably outgrown the >>> shell prompt for anything but the smallest examples.

Regards.

--Paul.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users