471,337 Members | 1,120 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Re-Executing a variable

Hi, I've been having doubts on how to "re-execute" a varible(if thats how its mentioned), for example:

a=raw_input("name: ")
if a=="user":
print "wrong!"
exec('a')

I dont want to use def()'s or anything like that, I just simply want Python to go back and re-execute 'a'. How do I do this without the need of def() or while loops?

Thanks!
Sep 18 '07 #1
1 915
bartonc
6,596 Expert 4TB
Hi, I've been having doubts on how to "re-execute" a varible(if thats how its mentioned), for example:

a=raw_input("name: ")
if a=="user":
print "wrong!"
exec('a')

I dont want to use def()'s or anything like that, I just simply want Python to go back and re-execute 'a'. How do I do this without the need of def() or while loops?

Thanks!
Nope, can't do it. There is no "goto" in python. Period. Loops are the simple way to do what you seek. There are also "exotic flow control" techniques which I won't discuss here.
Sep 18 '07 #2

Post your reply

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

Similar topics

4 posts views Thread by Craig Bailey | last post: by
1 post views Thread by Chris | last post: by
11 posts views Thread by James | last post: by
4 posts views Thread by Alan Walkington | last post: by
1 post views Thread by John Ryan | last post: by
10 posts views Thread by James | last post: by
8 posts views Thread by Beowulf | last post: by
8 posts views Thread by Lothar Scholz | last post: by
1 post views Thread by joost | last post: by
2 posts views Thread by sky2070 | last post: by
reply views Thread by rosydwin | last post: by

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.