In article <7d95c0d3-718d-4958-9364-263c833f1...@i24g2000yqa.googlegroups.com>, sturlamolden <sturlamol...@yahoo.no> wrote:
> On 3 Aug, 02:47, Roy Smith <r...@panix.com> wrote: > > > This one I don't understand. Yes, I get RAII, but surely there are > > valid reasons to allocate memory outside of constructors. Containers > > which resize themselves (such as std::vector) are one obvious example. > > That is because an exception might skip an arbitrarily placed delete[] > or std::fclose when it rewinds the stack... Well, OK, but there's still nothing wrong with allocating memory outside of constructors, as long as you make sure the destructor cleans it up. Or you have made some other arrangements to make sure it's cleaned up (try/catch, auto_pointer, etc).
-- http://mail.python.org/mailman/listinfo/python-list