Weak reference auf bound method
Von: Ole Streicher (ole-usenet-spam@gmx.net) [Profil]
Datum: 02.10.2009 10:50
Message-ID: <ytz7hve41tc.fsf@news.ole.ath.cx>
Newsgroup: de.comp.lang.python
Datum: 02.10.2009 10:50
Message-ID: <ytz7hve41tc.fsf@news.ole.ath.cx>
Newsgroup: de.comp.lang.python
Hallo, im Zusammenhang mit dem Async-Problem ist mir noch etwas aufgefallen -- "Bound methods" verhalten sich in weakrefs komisch: class MyClass(object): def myfunc(self): pass o = MyClass() print o.myfunc >>>> <bound method MyClass.myfunc of <__main__.MyClass object at 0xc675d0>> import weakref r = weakref.ref(o.myfunc) print r() >>>> None Nanu? Das Objekt "o" gibt es doch noch, und damit auch die passende bound method "o.myfunc". Die weakref behauptet aber, sie gäbe es nicht mehr. Wie kann ich erreichen, dass die Referenz erhalten bleibt, solange "o" lebt? Viele Grüße Ole[ Auf dieses Posting antworten ]
Antworten
- Stefan Behnel (02.10.2009 13:38)
- Ole Streicher (02.10.2009 13:50)
- Stefan Behnel (02.10.2009 13:56)
- Ole Streicher (02.10.2009 14:05)
