Heloop!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Netwatcher
    New Member
    • Sep 2008
    • 58

    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?
  • mac11
    Contributor
    • Apr 2007
    • 256

    #2
    maybe what you want is a debugger:
    Source code: Lib/pdb.py The module pdb defines an interactive source code debugger for Python programs. It supports setting (conditional) breakpoints and single stepping at the source line level, i...

    Otherwise I don't understand the question

    Comment

    • Laharl
      Recognized Expert Contributor
      • Sep 2007
      • 849

      #3
      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.

      Comment

      • Netwatcher
        New Member
        • Sep 2008
        • 58

        #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.)

        Comment

        • Netwatcher
          New Member
          • Sep 2008
          • 58

          #5
          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)

          Comment

          • Laharl
            Recognized Expert Contributor
            • Sep 2007
            • 849

            #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.

            Comment

            • Netwatcher
              New Member
              • Sep 2008
              • 58

              #7
              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.

              Comment

              • Netwatcher
                New Member
                • Sep 2008
                • 58

                #8
                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_i nput('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_i nput("Wat is Yo Momma's maiden Neim? \n"*1)
                if maideName=="iro n":
                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?

                Comment

                • Laharl
                  Recognized Expert Contributor
                  • Sep 2007
                  • 849

                  #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?

                  Comment

                  • Netwatcher
                    New Member
                    • Sep 2008
                    • 58

                    #10
                    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!

                    Comment

                    • Laharl
                      Recognized Expert Contributor
                      • Sep 2007
                      • 849

                      #11
                      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.

                      Comment

                      • Subsciber123
                        New Member
                        • Nov 2006
                        • 87

                        #12
                        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.

                        Comment

                        Working...