Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 23rd, 2004, 8:28 PM   #1
techbota
Newbie
 
Join Date: Jul 2004
Posts: 4
Rep Power: 0 techbota is on a distinguished road
HELp. Im following beginners tutorials for python
'
Everything was doing fine. I was able to open the PY files by double clicking them. The cmd prompt would open and run the stuff.

Now all the sudden I run the program it as me for my inputs but after the last input the cmd window closes.

Ive tried restarting windows and completely shutting down. Still when it gets to the point of returning a answer it closes.

All these programs worked 10 minutes before it stopped working so im not sure what is happening.

The programs run fine in the python window.
techbota is offline   Reply With Quote
Old Jul 23rd, 2004, 9:28 PM   #2
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
is your command prompt processing the script, then closing? or is it "not working"... need more clarification.

if it is you run the cmd prompt and want the window to remain open try this...

cmd /K yourCommand

this call to cmd carries out the command specified in your Command and the cmd window remains... by default i believe a call to cmd is /C which closes it before you see output.

as far as why it worked before and now it doesn't... sounds like a fluke.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Jul 23rd, 2004, 10:45 PM   #3
techbota
Newbie
 
Join Date: Jul 2004
Posts: 4
Rep Power: 0 techbota is on a distinguished road
Yes it appears to be processing it and then closing.

Im not running it from the command prompt.

Im double clicking the pythong script and it opends the command prompt. I enter the info it ask for and it runs and closes so fast I cant see the reslts.....

Although the first couple times it worked fine and stayed open.

Her is a sample script that im talking about. Althou it the same with all of them that worked before. Pleas eodont laugh im just learning.

#This program calculates the perimeter and area of a rectangle
print "Calculate information about a rectangle"
length = input("Length:")
width = input("Width:")
print "Area",length*width
print "Perimeter",2*length+2*width
techbota is offline   Reply With Quote
Old Jul 23rd, 2004, 10:46 PM   #4
techbota
Newbie
 
Join Date: Jul 2004
Posts: 4
Rep Power: 0 techbota is on a distinguished road
Sorry for the spelling I must have been typing too fast and its late
techbota is offline   Reply With Quote
Old Jul 24th, 2004, 12:35 AM   #5
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
This is a very very common problem, windows will only keep the command prompt window open as long as it needs to, so once your script is done executing the window is closed, even if you have not had a chance to read the output.

Open up an actual command prompt manually (run -> type |cmd| -> [ENTER]) and then run your scripts by giving commands at the prompt to execute the python scripts, force your python script to pause just before the program terminates, you can pass the system command "PAUSE" to do this for you if you want.
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Jul 24th, 2004, 1:22 AM   #6
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Ahhh. I failed to mention what I use the most... PAUSE via system shell. There are other compiler, etc options and preferences that can be set to do this for you as well.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Jul 24th, 2004, 8:24 PM   #7
techbota
Newbie
 
Join Date: Jul 2004
Posts: 4
Rep Power: 0 techbota is on a distinguished road
Wow finally a python forum that delivers. This is the only one that answered me....lol

Obviously im the ultimate newb. I map for UT alot and im fairly comfortable with my meager modeling skills and I want to learn some programming.

So you have to realize things as simple as running a script at the cmd promt is foriegn to me. I have done it before but where I falter is finding the program and running it. I type run Hello15.py (the name of the script) at the cmd promt and it says run is not a command.

Also what is the right syntax for using pause in my script and would I make it the last command?????


Also another question that came up today. I thought that once I wrote the code and saved and ran it. That it was compiling the code. But I noticed that it wasnt as I opened it in notepad. Shouldnt I be compiling it??? Although in the tutorial it said nothing of it.

I appreciate the time you guys take answering what is probably trivial questions to you.

Oh and one more thing that has crossed my mind. Am I learning the right programing language. Or should I be dabling in something like VB instead. I was told that if you want your program to have a GUI interface you should be using VB and that python was more for text type of programs.
techbota is offline   Reply With Quote
Old Jul 25th, 2004, 3:38 PM   #8
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Very trivial, true... but hey, all of us were there at some point. You'll find coding, hopefully, to be very rewarding, as I have.
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Jul 25th, 2004, 3:58 PM   #9
Kylixen
Programmer
 
Kylixen's Avatar
 
Join Date: Jun 2004
Location: SC
Posts: 60
Rep Power: 5 Kylixen is on a distinguished road
Send a message via AIM to Kylixen Send a message via MSN to Kylixen
Quote:
Originally posted by techbota@Jul 25 2004, 01:24 AM
Wow finally a python forum that delivers. This is the only one that answered me....lol

Obviously im the ultimate newb. I map for UT alot and im fairly comfortable with my meager modeling skills and I want to learn some programming.

So you have to realize things as simple as running a script at the cmd promt is foriegn to me. I have done it before but where I falter is finding the program and running it. I type run Hello15.py (the name of the script) at the cmd promt and it says run is not a command.

Also what is the right syntax for using pause in my script and would I make it the last command?????


Also another question that came up today. I thought that once I wrote the code and saved and ran it. That it was compiling the code. But I noticed that it wasnt as I opened it in notepad. Shouldnt I be compiling it??? Although in the tutorial it said nothing of it.

I appreciate the time you guys take answering what is probably trivial questions to you.

Oh and one more thing that has crossed my mind. Am I learning the right programing language. Or should I be dabling in something like VB instead. I was told that if you want your program to have a GUI interface you should be using VB and that python was more for text type of programs.
"Also what is the right syntax for using pause in my script and would I make it the last command?????"

You could just have it wait for input that does nothing at the end of the script. A loan raw_input at the end.

"Also another question that came up today. I thought that once I wrote the code and saved and ran it. That it was compiling the code. But I noticed that it wasnt as I opened it in notepad. Shouldnt I be compiling it??? Although in the tutorial it said nothing of it."

Python is an interpreted language. When you interpret the program, it compiles it in the PWD as "file.pyc". The c obviously stands for compiled. You can run that independantly, and distributed it.

"Oh and one more thing that has crossed my mind. Am I learning the right programing language. Or should I be dabling in something like VB instead. I was told that if you want your program to have a GUI interface you should be using VB and that python was more for text type of programs."

This is true, in a sense. Python is a great language to learn how to program with. You aren't going to be jumping straight into any GUI any time soon, so why rush to a language that quickly facilitates it? Python is a wonderful tool, and it is worth learning for anybody. I am sure there is some kind of GTK/QT extensions you can use with Python, it isn't really practical though. I would suggest you learn C/C++ for GUI apps, but ride python out. It's going to be much more beneficial than you can imagine at this point.
__________________
ALLOW IMAGES IN SIGNATURES NOW
Kylixen is offline   Reply With Quote
Old Jul 26th, 2004, 10:11 PM   #10
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 707
Rep Power: 5 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
The easiest way to keep the command prompt open for me when I just double click is this. It just calls the pause command for msdos.

import os 

'''
All of your python code here.
'''
print "\n"
os.system('pause')

Then it will ask you to press any key to continue so that you have time to read what you need to read.
thechristelegacy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:28 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC