Ubuntu Pastebin

Paste from barry at Wed, 28 Oct 2015 20:02:09 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
class Foo:
    def __del__(self):
        print('freed', self)


def make():
    for i in range(2):
        yield Foo()

from sys import getrefcount as rc

for obj in make():
    x = make()
    print(rc(x))
    del x
Download as text