Question about generators.

K

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
 
P

Paul McGuire

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
.... yield 1
....
 
K

kiwwisk

Thanks for reply :)
I'm little sceptic about this code:'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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,293
Latest member
Hue Tran

Latest Threads

Top