Changes between Initial Version and Version 1 of Ticket #40, comment 4
- Timestamp:
- 01/05/16 14:59:32 (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #40, comment 4
initial v1 1 Another possible solution. 1 Another possible solution. weakref+with 2 2 3 3 === … … 9 9 self.parent = weakref.ref(parent) 10 10 #self.parent =parent 11 print ' Foo', self.id, 'born'11 print 'child', self.id, 'new' 12 12 13 13 def __del__(self): 14 print 'Foo', self.id, 'died' 14 print 'child', self.id, 'del' 15 16 def __exit__(self, type, value, traceback): 17 print 'child', self.id, 'exit' 18 19 def __enter__(self): 20 print 'child', self.id, 'enter' 15 21 16 22 … … 18 24 def __init__(self, id): 19 25 self.id = id 20 self.foo = FooType(id, self) 21 print 'Bar', self.id, 'born' 26 print 'main', self.id, 'new' 27 with FooType(id, self) as self.foo: 28 pass 22 29 23 30 def __del__(self): 24 print ' Bar', self.id, 'died'31 print 'main', self.id, 'del' 25 32 26 33 b = BarType(12)