Question about generators.

2006-01-30 Thread kiwwisk
Hi,
Is there a way for created generators to determine what function
created them?
Like for objects and classes function 'isinstance',

e.g.:

def gen1( ):
   yield 1

a = gen1( )

if isinstance( a, gen1 ) == True: #not functional.
   ...

Thanks for reply,
   Andrej

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about generators.

2006-01-30 Thread kiwwisk
Thanks for reply :)
I'm little sceptic about this code:
>>> a = gen1()
>>> a.gi_frame.f_code.co_name
'gen1'

will it be compatible with Python 2.3, 2.4, 2.5+ and future versions?
Seems very internal and subject of future change.

A.

-- 
http://mail.python.org/mailman/listinfo/python-list