Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 3rd, 2008, 04:50 AM
Member
 
Join Date: Sep 2008
Posts: 35
Exclamation 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?
Reply
  #2  
Old September 3rd, 2008, 01:55 PM
Familiar Sight
 
Join Date: Apr 2007
Posts: 158
Default

maybe what you want is a debugger:
http://docs.python.org/lib/module-pdb.html
Otherwise I don't understand the question
Reply
  #3  
Old September 3rd, 2008, 04:05 PM
Expert
 
Join Date: Sep 2007
Posts: 844
Default

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.
Reply
  #4  
Old September 4th, 2008, 02:05 AM
Member
 
Join Date: Sep 2008
Posts: 35
Default

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.)
Reply
  #5  
Old September 4th, 2008, 03:27 AM
Member
 
Join Date: Sep 2008
Posts: 35
Default

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)
Reply
  #6  
Old September 4th, 2008, 03:59 AM
Expert
 
Join Date: Sep 2007
Posts: 844
Default

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.
Reply
  #7  
Old September 4th, 2008, 07:08 AM
Member
 
Join Date: Sep 2008
Posts: 35
Default

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.
Reply
  #8  
Old September 6th, 2008, 04:22 AM
Member
 
Join Date: Sep 2008
Posts: 35
Default

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?
Reply
  #9  
Old September 6th, 2008, 04:58 AM
Expert
 
Join Date: Sep 2007
Posts: 844
Default

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?
Reply
  #10  
Old September 6th, 2008, 05:54 AM
Member
 
Join Date: Sep 2008
Posts: 35
Default

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!
Reply
  #11  
Old September 6th, 2008, 02:57 PM
Expert
 
Join Date: Sep 2007
Posts: 844
Default

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.
Reply
  #12  
Old September 7th, 2008, 04:15 PM
Subsciber123's Avatar
Member
 
Join Date: Nov 2006
Location: Eastern Time Zone
Posts: 83
Default

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

Bookmarks


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

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 Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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.
Post your question now . . .
It's fast and it's free

Popular Articles