|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
I looked around at the help files and stuff, but I coulded seem to find the code for restarting the program from the beginning. This is probally really simple...
Thanks.
__________________
Before you criticize someone, walk a mile in their shoes, that way when you do criticize them, you're a mile away and you have their shoes! |
|
#2
|
||||
|
||||
|
Well that's kinda vague for a question.
![]() Simple solution, you could try to put the program into a loop. like putting it inside a while 1: loop, making it an infinite loop (although you'll need a way to stop the process, then).Concretely, you could put your program in a file and get a second file like this: say you have your main program called "moo.py" with the cow() function (main function) . Then the second could look like : Code:
import moo
while 1:
moo.cow()
if raw_input('Run program again ? (Y/N)') == 'N':
break
Hope this is what you were looking for. |
|
#3
|
|||
|
|||
|
I think HTLCS: Learning with Python would be a good place for you to learn more.
|
|
#4
|
||||
|
||||
|
OK, I just thought that there might be a comand just for that or something.
Thanks for your help. |
|
#5
|
||||
|
||||
|
Solars way was probably the most practical, you could do it using system command's i'm sure but the loop is more Pythonic and cross platform.. Why exactly do you want to repeat a whole program over and over? Isn't this why we have functions and classes?
have fun, Mark. |
|
#6
|
||||
|
||||
|
Well, I don't want to repeat the whole program over and over, I just want to restart the program at a certain point.
|
|
#7
|
||||
|
||||
|
Ok, now if I understand what you really want, you're asking for the continue keyword. I suppose you're familiar with the break statement, which stops and then exits a loop : continue stops it but does not exit the loop. It just starts anew. So you just have to add something like:
Code:
if SomeConditionYouDecide: continue else: #put rest of program here Hope that was of help. |
|
#8
|
||||
|
||||
|
Thats what I was looking for...
Thanks. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Newbie Question? :) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|