Since nobody else mentioned this...
Python classes have a magic method called __del__ which is usually
called just before an object is garbage-collected. Further, Python
uses reference-counting to tell when an object is no longer
accessible. This means that if your resource classes define __del__
On Jul 9, 7:30 pm, Lie Ryan wrote:
> brasse wrote:
> > Hello!
> > I have been thinking about how write exception safe constructors in
> > Python. By exception safe I mean a constructor that does not leak
> > resources when an exception is raised within it. The following is an
> > example of one po
brasse wrote:
> Hello!
> I have been thinking about how write exception safe constructors in
> Python. By exception safe I mean a constructor that does not leak
> resources when an exception is raised within it. The following is an
> example of one possible way to do it:
First, your automatic clea
On Jul 6, 11:15 pm, Scott David Daniels wrote:
> brasse wrote:
> > I have been thinking about how write exception safe constructors in
> > Python. By exception safe I mean a constructor that does not leak
> > resources when an exception is raised within it.
>
> ...
> > As you can see this is less
En Mon, 06 Jul 2009 18:15:44 -0300, Scott David Daniels
escribió:
brasse wrote:
I have been thinking about how write exception safe constructors in
Python. By exception safe I mean a constructor that does not leak
resources when an exception is raised within it.
...
> As you can see this i
brasse wrote:
I have been thinking about how write exception safe constructors in
Python. By exception safe I mean a constructor that does not leak
resources when an exception is raised within it.
...
> As you can see this is less than straight forward. Is there some kind
> of best practice tha
Hello!
I have been thinking about how write exception safe constructors in
Python. By exception safe I mean a constructor that does not leak
resources when an exception is raised within it. The following is an
example of one possible way to do it:
class Foo(object):
def __init__(self, name, f