Jump to content


Photo

Chapter 2


  • Please log in to reply
5 replies to this topic

#1 sgarica

sgarica

    New Member

  • Members
  • Pip
  • 3 posts

Posted 09 May 2011 - 06:06 PM

Ok so i have a problem i am using Ubuntu 10.10, and IDLE 3.0 python. When i write " print_lol(movies)" it printes out but when i start to write "comments" it goes well as soon as i apply "else: print(each_item)" (i attached the image ) my "triple chevron" does not come back it does not restart as it applys in the book.

Attached Thumbnails

  • HFP.png
  • nester.py.png


#2 paulbarry

paulbarry

    Advanced Member

  • O'Reilly Author
  • PipPipPipPipPipPipPipPip
  • 307 posts

Posted 10 May 2011 - 04:19 AM

Follow the advice in the book and *don't attempt* to type this amount of code into the IDLE shell (at the >>> prompt). Rather, open up an new IDLE edit window and type your code in there. Once you save your file, press F5 to run it and be taken back to the shell. You should be good-to-go then.

[BTW: I think the trouble you are having is that you took at newline after the >>> and before the start of you triple-quote, """ - my guess is that you have confused the shell.]

Hope this helps.

--Paul.

#3 sgarica

sgarica

    New Member

  • Members
  • Pip
  • 3 posts

Posted 10 May 2011 - 12:28 PM

Follow the advice in the book and *don't attempt* to type this amount of code into the IDLE shell (at the >>> prompt). Rather, open up an new IDLE edit window and type your code in there. Once you save your file, press F5 to run it and be taken back to the shell. You should be good-to-go then.

[BTW: I think the trouble you are having is that you took at newline after the >>> and before the start of you triple-quote, """ - my guess is that you have confused the shell.]

Hope this helps.

--Paul.

Ok so after i did that and press F5 opens another shell but i get invalid syntax
and another thing is because i am running ubuntu i have trouble running the setup.py i type in terminal sudo /home/user/nester.pynester.png

#4 paulbarry

paulbarry

    Advanced Member

  • O'Reilly Author
  • PipPipPipPipPipPipPipPip
  • 307 posts

Posted 11 May 2011 - 12:22 AM

You've copied the entire session into the IDLE edit window, and you only need to copy the code. So, make sure the bit that starts "def print_lol(... " is all that's in your edit window. Note that the IDLE shell is an environment that allows you to experiment with snippets of code, whereas the edit window lets you write and work with larger amounts of code. All of the >>> stuff in the shell is not valid Python code.

Hope this helps.

--Paul.

#5 sgarica

sgarica

    New Member

  • Members
  • Pip
  • 3 posts

Posted 11 May 2011 - 12:24 PM

I did what you said same problem could you write an example from the book, so i see what i am doing wrong please.

#6 paulbarry

paulbarry

    Advanced Member

  • O'Reilly Author
  • PipPipPipPipPipPipPipPip
  • 307 posts

Posted 12 May 2011 - 12:27 AM

I did what you said same problem could you write an example from the book, so i see what i am doing wrong please.


Please see page 35 of Chapter 2. It's all there.

--Paul.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users