Re: Python generators (coroutines)

2008-04-23 Thread rocco . rossi
> Anyway, if you have a blocking operation, the only solution is to use > a thread or a separate process. > > Michele Simionato That's what I thought. It was in fact rather obvious, but I wanted to be sure that I hadn't overlooked some arcane possibility (ex. with the use of exceptions or somet

Re: Python generators (coroutines)

2008-04-23 Thread Michele Simionato
On Apr 23, 8:26 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > On Wed, 23 Apr 2008 10:53:03 -0700 (PDT), Michele Simionato: > You could have #2. It's a trivial variation of sending a value. For > example, > > http://twistedmatrix.com/trac/browser/trunk/twisted/internet/defer.py... > > Jean-

Re: Python generators (coroutines)

2008-04-23 Thread Jean-Paul Calderone
On Wed, 23 Apr 2008 10:53:03 -0700 (PDT), Michele Simionato <[EMAIL PROTECTED]> wrote: On Apr 23, 4:17 pm, [EMAIL PROTECTED] wrote: I would really like to know more about python 2.5's new generator characteristics that make them more powerful and analogous to coroutines. Is it possible for inst

Re: Python generators (coroutines)

2008-04-23 Thread Michele Simionato
On Apr 23, 4:17 pm, [EMAIL PROTECTED] wrote: > I would really like to know more about python 2.5's new generator > characteristics that make them more powerful and analogous to > coroutines. Is it possible for instance to employ them in situations > where I would normally use a thread with a blocki

Re: Python generators (coroutines)

2008-04-23 Thread Jean-Paul Calderone
On Wed, 23 Apr 2008 07:17:46 -0700 (PDT), [EMAIL PROTECTED] wrote: I would really like to know more about python 2.5's new generator characteristics that make them more powerful and analogous to coroutines. Is it possible for instance to employ them in situations where I would normally use a thre

Re: Python generators (coroutines)

2008-04-23 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: I would really like to know more about python 2.5's new generator characteristics that make them more powerful and analogous to coroutines. Is it possible for instance to employ them in situations where I would normally use a thread with a blocking I/O (or socket) opera

Re: Python Generators

2008-03-18 Thread Marius Gedminas
On Mar 16, 9:24 am, Matt Nordhoff <[EMAIL PROTECTED]> wrote: > mpc wrote: > > def concatenate(sequences): > >     for seq in sequences: > >         for item in seq: > >             yield item > > You should check out itertools.chain(). It does this. You call it like > "chain(seq1, seq2, ...)" inste

Re: Python Generators

2008-03-16 Thread Matt Nordhoff
mpc wrote: > def concatenate(sequences): > for seq in sequences: > for item in seq: > yield item You should check out itertools.chain(). It does this. You call it like "chain(seq1, seq2, ...)" instead of "chain(sequences)" though, which may be a problem for you. The res

Re: Python Generators

2008-03-15 Thread Peter Otten
mpc wrote: > I am trying to write a while loop that will iterate over generators to > capture all the headers of FFCache directories. However, the > generators embedded within the argument of another generator do not > seem to re-initiate. the example below loops through and initiates the > genera

Re: Python Generators

2008-03-15 Thread sturlamolden
On 15 Mar, 21:35, mpc <[EMAIL PROTECTED]> wrote: > generator embedded in the argument only once. Can anyone explain while > the generator will not re-initiate, and suggest a simple fix? I am not sure what you are trying to do, but it seems a bit confused. >>> def concat(seq): for s in