Thanks Steven and Gabriel. Those are very informative responses.
In my case my resource isn't bound to a lexical scope, but the:
def __del__(self,
delete_my_resource=delete_my_resource):
pattern works quite well. I've made sure to prevent my class from
being part of a circular
* Brendan Miller:
Thanks Steven and Gabriel. Those are very informative responses.
In my case my resource isn't bound to a lexical scope, but the:
def __del__(self,
delete_my_resource=delete_my_resource):
pattern works quite well. I've made sure to prevent my class from
I'm used to C++ where destrcutors get called in reverse order of construction
like this:
{
Foo foo;
Bar bar;
// calls Bar::~Bar()
// calls Foo::~Foo()
}
I'm writing a ctypes wrapper for some native code, and I need to manage some
memory. I'm wrapping the memory in a python class
On 2010-04-07 15:08:14 -0700, Brendan Miller said:
When doing this, I noticed some odd behaviour. I had code like this:
def delete_my_resource(res):
# deletes res
class MyClass(object):
def __del__(self):
delete_my_resource(self.res)
o = MyClass()
What happens is that as the
En Wed, 07 Apr 2010 19:08:14 -0300, Brendan Miller catph...@catphive.net
escribió:
I'm used to C++ where destrcutors get called in reverse order of
construction
like this:
{
Foo foo;
Bar bar;
// calls Bar::~Bar()
// calls Foo::~Foo()
}
That behavior is explicitly