Friend and python(very basic)

Started by
11 comments, last by biggjoee5790 17 years ago
A good friend of mine decided he was going to start python programming. So he decided to take out from the library in our area The absolute beginners guide to python ,second edition. It wasn't long before he ran into a problem, and actually it was only 8 pages in. so hear is were the problem starts(note i know close to nothing about python and my friend is working so he wanted me to ask this forum), so the book says on the Python shell screen it said type in Print "Game Over" and then it said it will display as Game over in a dos like screen. He press enter and it went to >>> Print "game over" >>> game over The book went no further on this topic or possible errors. So then my friend opened up a new window and tried again, type in the same thing and saved it to exe and ran it and it said, synatax error. Is this what is supposed to happen, or what is my friend doing wrong? Thanks allot its really bothering him. Argos.
Advertisement
"Print" is supposed to be "print", python's case sensitive. I don't suppose that's the problem..? Not sure why it'd work the first time and not the second with "Print" at all.
Sorry i did the upper case.
Should it be a dos screen after the save and run?
Also why cant you use copy and paiste?

Edit-i tried the it again and it brought me back to the shell screen and went
=============================restart
>>>game over.

is this whats suppose to happen.

Lastly, the book has dos screen(black screen with text) after every example, how is that done?
What do you mean by "saved it to an exe?" A python file is a script. It cannot be "saved as an exe" without quite a bit of procedure (using py2exe). He would have to save his script as a standard .py file, then execute it by typing something like "\python25\python.exe myscript.py"
There exist two python interpreters with the standard package.

The DOS style black and white version and the IDLE, which includes a syntax highlighted interpreter. It sounds like your friends book used the dos version. They both behave the same.
Quote:Michael TanczosCut that shit out. You shouldn't be spying on other people.. especially your parents. If your dad wanted to look at horses having sex with transexual eskimo midgets, that's his business and not yours.
If your friend wants "Game Over" to print on the "DOS" screen that your talking about, he has to save the program and open it outside of IDLE, he cant just click run because that will run the program in IDLE, not in the "DOS" screen. Tell him to save it to his desktop, then click on it. Now heres a problem he will encounter: Because the program is made to print the words "Game Over", It will do that and then exit. The problem is that it will print and exit so quickly that the window will open and close in the blink of an eye. In order to get it to stay open, I will show you the method that is shown in the book he is using(Im using the same book currently :)

heres how it should be made:

print "Game Over"raw_input("Press Enter to exit the program")



Although he might not know what that last line means, it is necessary to keep the window running, until you press enter. The author explains this in the book very early so he should learn this soon.
Sounds good, One problem is my friend is using vista and anytime he tries to do anything besides the internet it says he is stepping over boundaries.
Also just wondering since you are using the same book, why doesn't it in the beginning use the idle output but the "dos" one?
One last note
So having the program play its self out on the idle shell out put will work the same way?
thanks for your patience
argos
Quote:Original post by Argos
Sounds good, One problem is my friend is using vista and anytime he tries to do anything besides the internet it says he is stepping over boundaries.
Also just wondering since you are using the same book, why doesn't it in the beginning use the idle output but the "dos" one?
One last note
So having the program play its self out on the idle shell out put will work the same way?
thanks for your patience
argos


Ok as far as Vista goes, I cant help ya cause Ive never used it. As for why the author shows his programs running in the "dos" window and not IDLE, it seems to be just a matter of preference. Also, when you save a script and want to run the program you have made, the program will run in the "dos" window and not in IDLE. Programs only run in the IDLE window when you run them from inside IDLE.
And to your last question, yes it will run the program the same way, but there is one difference. The difference is what I explained before about it closing before you can even see the program. If you run a program in the IDLE window, when the program ends, IDLE will not close. The shell will just end and start a new shell. If you run the programs in the "dos" window, the window will close as soon as the program ends. In some situations, this can be quite annoying, like for example making a program that simply prints a word. If you run a print program in IDLE, you can run it without worrying about anything shutting off. On the other hand, If you run it in the "dos" window, it will close before you can even see it. Hope I was clear and helpful. And by the way I beleive the "dos" window is called the console.

Just one last thing to ask(you have been really helpful so far thanks for that)
Will it carry out equations in the idle shell form? And my friend one day wants to try this with blender, so is the idle form able to work with that? And lastly in the end it shows two short games you can make, if you don't do the console method, will it still run?
Also one of the examples tic tac toe uses the console screen. At that point using it is mandatory?
thanks allot
argos
edit---------
My friend tried to open up python and vista displayed an error message saying socket error. He tried to go to the windows firewall but even after trying to add python idle to exceptions, its still not there. Also it says socket error.

[Edited by - Argos on April 8, 2007 9:46:32 AM]
Quote:Original post by Argos
Just one last thing to ask(you have been really helpful so far thanks for that)
Will it carry out equations in the idle shell form? And my friend one day wants to try this with blender, so is the idle form able to work with that? And lastly in the end it shows two short games you can make, if you don't do the console method, will it still run?
Also one of the examples tic tac toe uses the console screen. At that point using it is mandatory?
thanks allot
argos
edit---------
My friend tried to open up python and vista displayed an error message saying socket error. He tried to go to the windows firewall but even after trying to add python idle to exceptions, its still not there. Also it says socket error.


First of all.. yes the shell can do any equations. You can even import modules into the shell form to use. The point of the shell is to test out pieces of your program before you actually add them. Have a function you want to use but not sure how it works, you can test it in the shell without altering your program at all. As far as blender goes, I dont know much about it. I do know that blender has Python bindings inside of it, enabling you to write Python code inside of blender to use in your animations. Your friend is making too big a deal of the IDLE vs Console thing. Any text based program can run in either the console window or the IDLE shell, it doesnt matter at all. Now When you deal with the games at the end that involve graphics, neither the console or IDLE will be used. You make a whole new type of window to run graphics, which you will be taught in the book. Now for the socket error, If your talking about the same one I used to get, Im not really sure what to tell you. Apparently IDLE needs to have some sort of connection to the internet for some reason, Im not sure why. I used to get the error all the time (In windows XP) but after a while it just stopped. Just remember that the IDLE screen that has a >>> before you type, is used for testing code, not for writing programs. You have to open a new script window to write programs, which is just a blank screen. Hope That helps

This topic is closed to new replies.

Advertisement