The right way to 'call' a class attribute inside the same class
python at lucidity.plus.com
Thu Dec 15 19:18:06 EST 2016
On 13/12/16 06:14, Gregory Ewing wrote:
> Ned Batchelder wrote:
>> if a C++ constructor raises an exception, will the corresponding
>> be run, or not? (No, because it never finished making an object of
>> type T.)
> So it just leaks any memory that's been allocated by
> the partially-run constructor?
If you're referring to resources in general that a constructor (in the
C++ sense) allocates - memory, file descriptors, whatever - then it's up
to the constructor to release those resources before throwing the
exception should something fail. Destructors are not executed for
objects that were not constructed.
If the constructor is not written to that standard, then yes - it will
The memory allocated for the _object_ itself will be released though.
More information about the Python-list