[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)
>
On Tuesday 12 July 2005 10:28 am, Tim Golden wrote:
> [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...
>
>
>
> Presumably you
"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
[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...
Presumably you meant "cue discussion..."
(Ducks & runs)
TJG
__
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
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 make_one_thing(gr
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 itertools.cycle(range(le
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?
Define a flag first:
keepGoing = True
> while 1:
while keepGoing:
> for x in xrange(len(group)):
> try:
...
> if match == target:
> print "Co
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 loop
10 matches
Mail list logo