[Baypiggies] introspecting for generator vs non-generator function
aleaxit at gmail.com
Sat Nov 15 05:04:48 CET 2008
On Fri, Nov 14, 2008 at 7:44 PM, Matt Good <matt at matt-good.net> wrote:
> On Nov 14, 2008, at 4:07 PM, Alex Martelli wrote:
>> Just in case anybody's interested, please see
> There's a co_flags for that:
> "The following flag bits are defined for co_flags: ... bit 0x20 is set if
> the function is a generator."
> def is_generator(func):
> return bool(func.func_code.co_flags & 0x20)
> I also tried posting a comment, but maybe it's awaiting moderation.
Yes it was -- I just approved it. Thanks! If there's one thing that
makes me even happier than teaching, it's learning!-)
More information about the Baypiggies