Sturla Molden wrote: > Rustom Mody <rustompm...@gmail.com> wrote: > >> The case of RAII vs gc is hardly conclusive: >> >> http://stackoverflow.com/questions/228620/garbage-collection-in-c-why > > The purpose of RAII is not to be an alternative to garbage collection > (which the those answers imply), but to ensure deterministc execution of > setup and tear-down code. The Python equivalent of RAII is not garbage > collection but context managers. > > Those answers is a testimony to how little the majority of C++ users > actually understand about the language. > > > > A C++ statement with RAII like > > { > Foo bar(); > // suite > } > > is not equivalent to > > bar = Foo() > > in Python. It actually corresponds to > > with Foo() as bar: > <suite>
Nice answer! I'm not qualified to tell whether you are right or not, but what you say has the ring of truth about it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list