isgenerator(...) - anywhere to be found?

2008-01-22 Thread Diez B. Roggisch
For a simple greenlet/tasklet/microthreading experiment I found myself in the need to ask the question isgenerator(v) but didn't find any implementation in the usual suspects - builtins or inspect. I was able to help myself out with a simple (out of my head, hope its def isgenerator(v):

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Stefan Rank
on 22.01.2008 14:20 Diez B. Roggisch said the following: def isgenerator(v): def _g(): yield return type(v) == type(_g()) But I wonder why there is no such method already available? This tests for generator objects, and you could also use:: return type(v) is

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Jean-Paul Calderone
On Tue, 22 Jan 2008 14:20:35 +0100, Diez B. Roggisch [EMAIL PROTECTED] wrote: For a simple greenlet/tasklet/microthreading experiment I found myself in the need to ask the question isgenerator(v) but didn't find any implementation in the usual suspects - builtins or inspect. I was able to help

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Diez B. Roggisch
Jean-Paul Calderone wrote: On Tue, 22 Jan 2008 14:20:35 +0100, Diez B. Roggisch [EMAIL PROTECTED] wrote: For a simple greenlet/tasklet/microthreading experiment I found myself in the need to ask the question isgenerator(v) but didn't find any implementation in the usual suspects - builtins or

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Diez B. Roggisch
Stefan Rank wrote: on 22.01.2008 14:20 Diez B. Roggisch said the following: def isgenerator(v): def _g(): yield return type(v) == type(_g()) But I wonder why there is no such method already available? This tests for generator objects, and you could also use:: return

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Diez B. Roggisch
Jean-Paul Calderone wrote: On Tue, 22 Jan 2008 15:15:43 +0100, Diez B. Roggisch [EMAIL PROTECTED] wrote: Jean-Paul Calderone wrote: On Tue, 22 Jan 2008 14:20:35 +0100, Diez B. Roggisch [EMAIL PROTECTED] wrote: For a simple greenlet/tasklet/microthreading experiment I found myself in the need

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Jean-Paul Calderone
On Tue, 22 Jan 2008 15:15:43 +0100, Diez B. Roggisch [EMAIL PROTECTED] wrote: Jean-Paul Calderone wrote: On Tue, 22 Jan 2008 14:20:35 +0100, Diez B. Roggisch [EMAIL PROTECTED] wrote: For a simple greenlet/tasklet/microthreading experiment I found myself in the need to ask the question [snip]

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Paul McGuire
On Jan 22, 7:46 am, Stefan Rank [EMAIL PROTECTED] wrote: I also need to test for generator functions from time to time for which I use::    def _isaGeneratorFunction(func):        '''Check the bitmask of `func` for the magic generator flag.'''        return bool(func.func_code.co_flags

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Christian Heimes
Stefan Rank wrote: on 22.01.2008 14:20 Diez B. Roggisch said the following: def isgenerator(v): def _g(): yield return type(v) == type(_g()) But I wonder why there is no such method already available? This tests for generator objects, and you could also use:: return

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Jean-Paul Calderone
On Tue, 22 Jan 2008 15:52:02 +0100, Diez B. Roggisch [EMAIL PROTECTED] wrote: Jean-Paul Calderone wrote: [snip] Sorry, I still don't understand. Why is a generator different from any other iterator? Because you can use send(value) on it for example. Which you can't with every other

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Stefan Rank
on 22.01.2008 16:09 Paul McGuire said the following: On Jan 22, 7:46 am, Stefan Rank [EMAIL PROTECTED] wrote: I also need to test for generator functions from time to time for which I use:: def _isaGeneratorFunction(func): '''Check the bitmask of `func` for the magic generator

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread james . pye
On Jan 22, 6:20 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: For a simple greenlet/tasklet/microthreading experiment I found myself in the need to ask the question isgenerator(v) but didn't find any implementation in the usual suspects - builtins or inspect. types.GeneratorType exists in

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Steven Bethard
Diez B. Roggisch wrote: Jean-Paul Calderone wrote: On Tue, 22 Jan 2008 15:15:43 +0100, Diez B. Roggisch [EMAIL PROTECTED] wrote: Jean-Paul Calderone wrote: On Tue, 22 Jan 2008 14:20:35 +0100, Diez B. Roggisch [EMAIL PROTECTED] wrote: For a simple greenlet/tasklet/microthreading