W
Will McGugan
Hi,
I often write small classes in C++ the use the side effects of scope.
For example a CAutoLock class that locks a mutex in the constructor and
releases it in the destructor. Is this something that is easily
accomplished in Python? I'm guessing that using __init__ and __del__
would be roughly equivalent to this. But can can I be sure - with
garbage collection - that __del__ is called immediately at the point of
going out of scope?
Alternatively, should I give up this little idiom and use try / finally?
Thanks,
Will McGugan
I often write small classes in C++ the use the side effects of scope.
For example a CAutoLock class that locks a mutex in the constructor and
releases it in the destructor. Is this something that is easily
accomplished in Python? I'm guessing that using __init__ and __del__
would be roughly equivalent to this. But can can I be sure - with
garbage collection - that __del__ is called immediately at the point of
going out of scope?
Alternatively, should I give up this little idiom and use try / finally?
Thanks,
Will McGugan