473,324 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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?
Sep 3 '08 #1
11 1489
mac11
256 100+
maybe what you want is a debugger:
http://docs.python.org/lib/module-pdb.html
Otherwise I don't understand the question
Sep 3 '08 #2
Laharl
849 Expert 512MB
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.
Sep 3 '08 #3
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.)
Sep 4 '08 #4
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)
Sep 4 '08 #5
Laharl
849 Expert 512MB
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.
Sep 4 '08 #6
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.
Sep 4 '08 #7
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

Expand|Select|Wrap|Line Numbers
  1. import time
  2. while 1: #Need to get back here#
  3.     try:
  4.         actionman=raw_input('how much is 20-17 \n'*1)
  5.         if int(actionman)==3:
  6.             break
  7.         else:
  8.             print 'YOU'
  9.             time.sleep(3)
  10.             print 'ARE'
  11.             time.sleep(3)
  12.             print 'FAGS'
  13.     except ValueError:
  14.         print 'umm... thats not a number...not a cupcake either...'
  15.  
  16. while 2:
  17.     try:
  18.         maideName=raw_input("Wat is Yo Momma's maiden Neim? \n"*1)
  19.         if maideName=="iron":
  20.                                         print "Who's Yo Mamma"
  21.         else:
  22.             print "Ya dunn'o Yar Mamma?"
  23.              #From here#
  24.     except ValueError:
  25.         print 'LawLz'
  26. # being stupid is just a state of mind!
  27.  
  28.  
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?
Sep 6 '08 #8
Laharl
849 Expert 512MB
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?
Sep 6 '08 #9
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>>

Expand|Select|Wrap|Line Numbers
  1.  import stuff
  2. while 1:
  3.       try:
  4.          something
  5.       except monkey rage:
  6.                     blablabla
  7. while 2:
  8.        try:
  9.            something else 
  10. while 3:
  11.       try:
  12.           if something happens:
  13.                      break
  14.           elif you fail:
  15.             ???get back to the first loop??? 
  16.        except bananas:
  17.                  anything....
  18.  
  19.  
:

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!
Sep 6 '08 #10
Laharl
849 Expert 512MB
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.
Sep 6 '08 #11
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.
Sep 7 '08 #12

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.