 |

September 3rd, 2008, 04:50 AM
|
|
Member
|
|
Join Date: Sep 2008
Posts: 35
|
|
Heloop!
is there a way to tell the program, instead of just writing return(w/e) (which happens to navigate only to functions =/ correct me if im wrong{plz tell me im wrong}) i need navigate to a certain line inside a function and not starting the whole function again? is it realy possible? can i "call" a class?is there a big red balloon at the end of the world?
another helpful thing:
how do i start a function from something that is not a function?
|

September 3rd, 2008, 04:05 PM
|
|
Expert
|
|
Join Date: Sep 2007
Posts: 844
|
|
Please remember to provide a meaningful Title for any threads started (Please Use Appropriate Titles for New Threads!). This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.
That said, I have no idea what you're actually asking. I think you want to know how to call a function, but I'm really unsure. Maybe loops? Try to find a tutorial ( like this one) and maybe that will help more.
|

September 4th, 2008, 02:05 AM
|
|
Member
|
|
Join Date: Sep 2008
Posts: 35
|
|
hey, I'm sorry for the title, let me rephrase the question,how to start a certine command over and over until the input is as i want it to be, ( not within a function.)
|

September 4th, 2008, 03:27 AM
|
|
Member
|
|
Join Date: Sep 2008
Posts: 35
|
|
Quote:
|
Originally Posted by Netwatcher
hey, I'm sorry for the title, let me rephrase the question,how to start a certine command over and over until the input is as i want it to be, ( not within a function.)
|
oh crap, i meant "to go to a certine line (not the start of the w/e it is, a certine line within it) back and continue from that line (which forms a loop until the right keyword is typed)
|

September 4th, 2008, 03:59 AM
|
|
Expert
|
|
Join Date: Sep 2007
Posts: 844
|
|
What you do here is you use a while loop. Set your condition to be a boolean value and flip the boolean's value (True/False) after you've validated your input.
|

September 4th, 2008, 07:08 AM
|
|
Member
|
|
Join Date: Sep 2008
Posts: 35
|
|
Quote:
|
Originally Posted by Laharl
What you do here is you use a while loop. Set your condition to be a boolean value and flip the boolean's value (True/False) after you've validated your input.
|
so that's what the while is for...
great, thanks.
|

September 6th, 2008, 04:22 AM
|
|
Member
|
|
Join Date: Sep 2008
Posts: 35
|
|
Quote:
|
Originally Posted by Laharl
What you do here is you use a while loop. Set your condition to be a boolean value and flip the boolean's value (True/False) after you've validated your input.
|
im stuck...
here is an example of the prob
[CODE=python]import time
while 1: #Need to get back here#
try:
actionman=raw_input('how much is 20-17 \n'*1)
if int(actionman)==3:
break
else:
print 'YOU'
time.sleep(3)
print 'ARE'
time.sleep(3)
print 'FAGS'
except ValueError:
print 'umm... thats not a number...not a cupcake either...'
while 2:
try:
maideName=raw_input("Wat is Yo Momma's maiden Neim? \n"*1)
if maideName=="iron":
print "Who's Yo Mamma"
else:
print "Ya dunn'o Yar Mamma?"
#From here#
except ValueError:
print 'LawLz'
# being stupid is just a state of mind!
[/code]
i need to get back from a certine "while" in the middle of the script to another one in the start of it, is it possible?
|

September 6th, 2008, 04:58 AM
|
|
Expert
|
|
Join Date: Sep 2007
Posts: 844
|
|
Why do you need two while loops? In that example, the second while loop is completely extraneous. Just use its code after the try/catch in the first loop. I guess at this point you just surround the whole thing in another while loop, so that when you break it goes back to the outer loop?
|

September 6th, 2008, 05:54 AM
|
|
Member
|
|
Join Date: Sep 2008
Posts: 35
|
|
Quote:
|
Originally Posted by Laharl
Why do you need two while loops? In that example, the second while loop is completely extraneous. Just use its code after the try/catch in the first loop. I guess at this point you just surround the whole thing in another while loop, so that when you break it goes back to the outer loop?
|
its not only 2 loop, i got about 10 i want to do that sometime in the middle (5th, 6th loop) i will be sent back to the first loop.
better example to the problem>>
[CODE=python] import stuff
while 1:
try:
something
except monkey rage:
blablabla
while 2:
try:
something else
while 3:
try:
if something happens:
break
elif you fail:
???get back to the first loop???
except bananas:
anything....
[/code] :
only 1 loop needs to get back to the start, all the others need to get back to themselves.
copy/pasting the first while loop will just add 20 lines to the script, making it confusing and ugly!
|

September 6th, 2008, 02:57 PM
|
|
Expert
|
|
Join Date: Sep 2007
Posts: 844
|
|
What are you actually trying to do? Maybe loop 1 should be a function, if it has to be called multiple times. You could return the validated input, if that's what the loop is doing.
|

September 7th, 2008, 04:15 PM
|
 |
Member
|
|
Join Date: Nov 2006
Location: Eastern Time Zone
Posts: 83
|
|
You really need to look at some sort of Python tutorial. You seem to be going down the river without a paddle. Look into diveintopython.org and start there. Or look at the .chm help file that comes with the ActiveState version of python.
|
 |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|