[rbt]
What is the appropriate way to break out of this while loop if the for
loop finds a match?
while 1:
for x in xrange(len(group)):
try:
mix = random.sample(group, x)
make_string = ''.join(mix)
n = md5.new(make_string)
match
What is the appropriate way to break out of this while loop if the for
loop finds a match?
while 1:
for x in xrange(len(group)):
try:
mix = random.sample(group, x)
make_string = ''.join(mix)
n = md5.new(make_string)
match =
You either need to set a marker flag with multiple breaks - *or*
(probably more pythonic) wrap it in a try..except and raise an
exception. Define your own exception class and just trap for that if
you want to avoid catching other exceptions.
There is no single command to break out of multiple
rbt wrote:
What is the appropriate way to break out of this while loop if the for
loop finds a match?
Define a flag first:
keepGoing = True
while 1:
while keepGoing:
for x in xrange(len(group)):
try:
...
if match == target:
print
Thanks guys... that works great. Now I understand why sometimes logic
such as 'while not true' is used ;)
On Tue, 2005-07-12 at 10:51 -0400, Peter Hansen wrote:
rbt wrote:
What is the appropriate way to break out of this while loop if the for
loop finds a match?
Define a flag first:
rbt wrote:
What is the appropriate way to break out of this while loop if the for
loop finds a match?
while 1:
for x in xrange(len(group)):
another option not yet suggested is simply to collapse the two loops into a
single loop:
import itertools
for x in
On Tue, 12 Jul 2005 10:19:04 -0400, rbt wrote:
What is the appropriate way to break out of this while loop if the for
loop finds a match?
Refactor it into something easier to comprehend?
And comments never go astray.
(Untested. And my docstrings are obviously bogus.)
def
rbt wrote:
What is the appropriate way to break out of this while loop if the for
loop finds a match?
queue discussion why Python doesn't have a break N statement...
--
Jeremy Sanders
http://www.jeremysanders.net/
--
http://mail.python.org/mailman/listinfo/python-list
[Jeremy Sanders]
| rbt wrote:
|
| What is the appropriate way to break out of this while loop
| if the for
| loop finds a match?
|
| queue discussion why Python doesn't have a break N statement...
pedantry
Presumably you meant cue discussion...
/pedantry
(Ducks runs)
TJG
rbt [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
What is the appropriate way to break out of this while loop if the for
loop finds a match?
Make it a function and use a return statement to break out.
--
http://mail.python.org/mailman/listinfo/python-list
10 matches
Mail list logo