Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW)
OpenStudy (anonymous):

I'm on Ubuntu 10.04, and I everytime I run my program, it appears for a split second, then disappears (Problem Set 0) is anyone willing to check my code? It follows: # Problem Set 0 # Name: Cody Dostal # Collaborators: None # Time: 0:02 #! /usr/bin/env python # print "What is your first name? " FirstName = raw_input() print "What is your last name? " LastName = raw_input() print "Hello, " + FirstName + " " + LastName -------------END---------- What is my Problem with it?

OpenStudy (anonymous):

it runs fine in IDLE, just not when I save it as ps0.py

OpenStudy (anonymous):

I don't use Linux, but I can say that I always use IDLE for running and writing programs, never any sort of OS terminal. When I open a module (double clicking on one in the file management system of my mac or windows machines) it opens as a window in IDLE, and doesn't run until I specifically tell it to. From the line #! /usr/bin/env python and the "END" thing, it looks like you're using some flavor of terminal/command-line to run the code. There's probably a way to make that work, but if what you're looking for is just understanding Python, you won't miss anything by using IDLE.

OpenStudy (anonymous):

that happens with me to, because it runs the code and after it is done it closes. To prevent this, type the following on the last line: raw_input("Press any key to exit")

OpenStudy (anonymous):

@somnamnic: The -----------END------------ was just so I could show that that was the end of my code :) But I am starting to learn more about IDLE and am falling in love with it! @not4sale93: I did that, but it still does it :( New code: # Assignment: Problem Set 0 # Name: Cody Dostal # Collaborators: None # Time: 0:05 # firstname = raw_input('What is your first name? ') lastname = raw_input('What is your last name? ') print 'Hello, ' + firstname + ' ' + lastname raw_input("Press any key to exit")

OpenStudy (anonymous):

I noticed that if I open terminal and type in: Python ps0.py it runs fine it's only when I double click it and say "Run in Terminal" :\

OpenStudy (anonymous):

CodyWD, I think what you're running into is a normal behavior in Ubuntu. When you double-click to "Run in Terminal", the terminal window opens, runs the selected app, then closes. Nothing is telling the terminal window to stay open. You can "cheat" and add the following to the very end of your app (but don't brag about it to anyone :) ): raw_input("Press Enter to exit...") That line will keep the terminal window open long enough for you to see the output. But it's a kluge.

OpenStudy (emil):

CodyWD, a good alternative too see your code execution is to open a terminal and then execute the code. For example, press Ctrl+Alt+T to open a terminal, go to the folder where you have your .py file, and then execute like this : "python ps0.py". The terminal will remain open so you will see the results. Don't forget to enclose the Print arguments in ("brackets..") I hope this is useful...

OpenStudy (anonymous):

@Radly: That doesn't seem to work at all :\ @Emil: Already done, but I think I'm going to start sticking to IDLE for line-by-line testing, and PyScripter+Windows 7 for full programs haha

OpenStudy (anonymous):

I use ubuntu also and I don't have a problem when I use raw_input() to make it block. If your code looks like: #!/usr/bin/python # whereis python to make sure it's that path firstname = raw_input('What is your first name? ') lastname = raw_input('What is your last name? ') print 'Hello, ' + firstname + ' ' + lastname raw_input("Press any key to exit") EOF Then you should have no problems

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
MiamiHeat23: What are the levels in order????????
20 minutes ago 0 Replies 0 Medals
hasmenibrahim: Verbal motivation public communication
40 minutes ago 0 Replies 0 Medals
n32carrillo: i need help
1 hour ago 4 Replies 0 Medals
MiamiHeat23: Can anyone help me wit Latex? or bb code
1 minute ago 225 Replies 7 Medals
Speedy: How is everyone im new :) i just seeing what this is
2 hours ago 28 Replies 2 Medals
Kaloy69: Oral communication in context
1 hour ago 2 Replies 0 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!