<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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
>

How's this? (Written using Python 2.4)
-- Paul

>>> def gen1():
...     yield 1
...
>>> a = gen1()
>>> a.gi_frame.f_code.co_name
'gen1'
>>>


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

Reply via email to