Re: question about for cycle

2007-10-01 Thread Duncan Booth
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >>> Sometime it maybe a waste to generate all possible combinations of >>> i,j first. >> >> It doesn't; read about generator expressions at >> http://www.python.org/dev/peps/pep-0289/ >> >> George >> > Thanks, I didn't realize that. > > However,

Re: question about for cycle

2007-09-29 Thread [EMAIL PROTECTED]
George Sakkis wrote: > On Sep 29, 10:34 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: >> [EMAIL PROTECTED] wrote: >> >> > On 29 sep, 12:04, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >> > >> >> for i in generator_a: # the first "for" cycle >> >> for j in generator_b: >> >>

Re: question about for cycle

2007-09-29 Thread tokland
On 29 sep, 21:38, Zentrader <[EMAIL PROTECTED]> wrote: > ctr_a=0 > ctr_b=0 > while ctr_a < len(generator_a): > this_el_a = generator_a[ctr_a] > while ctr_b < len(generator_b): > this_el_b = generator_b[ctr_ b] > if something_happen: > ctr_b = len(generator

Re: question about for cycle

2007-09-29 Thread Zentrader
On Sep 29, 8:19 am, George Sakkis <[EMAIL PROTECTED]> wrote: > On Sep 29, 10:34 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > > > [EMAIL PROTECTED] wrote: > > > > On 29 sep, 12:04, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > > >> for i in generator_a: # the first "for" cycle

Re: question about for cycle

2007-09-29 Thread George Sakkis
On Sep 29, 10:34 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > On 29 sep, 12:04, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > > >> for i in generator_a: # the first "for" cycle > >> for j in generator_b: > >> if something_happen: > >>

Re: question about for cycle

2007-09-29 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > On 29 sep, 12:04, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > >> for i in generator_a: # the first "for" cycle >> for j in generator_b: >> if something_happen: >> # do something here ..., I want the outer cycle to break >>

Re: question about for cycle

2007-09-29 Thread tokland
On 29 sep, 12:04, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > for i in generator_a: # the first "for" cycle > for j in generator_b: > if something_happen: > # do something here ..., I want the outer cycle to break > break Do you like this? generator_

Re: question about for cycle

2007-09-29 Thread John Machin
On Sep 29, 8:04 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: [snip] > And I have another question. Which is the most efficient way to check if there > are duplicate items in a list ? The items in the list may cannot be hashed, so > set() may not work on the list. The following classic by Ti

Re: question about for cycle

2007-09-29 Thread Duncan Booth
Ant <[EMAIL PROTECTED]> wrote: > On Sep 29, 11:04 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > ... >> What should I do if I want the outer "for" cycle to continue or break >> ? If I put a "continue" or "break" in the inner cycle, it has no >> effect on the outer cycle. > ... > I guess

Re: question about for cycle

2007-09-29 Thread Peter Otten
Ant wrote: > On Sep 29, 11:04 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > ... >> What should I do if I want the outer "for" cycle to continue or break ? If I >> put a "continue" or "break" in the inner cycle, it has no effect on the outer >> cycle. > > I'd also be interested in the idi

Re: question about for cycle

2007-09-29 Thread Ant
On Sep 29, 11:04 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: ... > What should I do if I want the outer "for" cycle to continue or break ? If I > put a "continue" or "break" in the inner cycle, it has no effect on the outer > cycle. I'd also be interested in the idiomatic solution to this o

question about for cycle

2007-09-29 Thread [EMAIL PROTECTED]
Hi all, I have the following code: for i in generator_a: # the first "for" cycle for j in generator_b: if something_happen: # do something here ..., I want the outer cycle to break break What should I do if I want the outer "for" cycle to continue or brea