fork download
  1. def genfunc1(): yield
  2. def genfunc2(): yield
  3.  
  4. gen = genfunc1()
  5.  
  6. print(gen.gi_code is genfunc1.__code__)
  7. print(gen.gi_code is genfunc2.__code__)
  8.  
  9. # Consume the generator and test again, to demonstrate that this still works
  10. # when the generator is exhausted.
  11. list(gen)
  12. print(gen.gi_code is genfunc1.__code__)
  13. print(gen.gi_code is genfunc2.__code__)
Success #stdin #stdout 0.02s 9096KB
stdin
Standard input is empty
stdout
True
False
True
False