In article <2b473423-0a22-4f4d-943f-31ea2d602...@z10g2000yqb.googlegroups.com>,
sturlamolden  <sturlamol...@yahoo.no> wrote:
>
>And since this is comp.lang.python, I'll add in that this sometimes
>applies to Python as well. Python, like C++, can have the call stack
>rewinded by an exception. If we call some raw OS resource allocation,
>e.g. malloc or fopen using ctypes, we have to place a deallocation in
>__del__ (and make sure the object is newer put in a reference cycle).
>The safer option, however, is to use a C extension object, which is
>guaranteed to have the destructor called (that is, __dealloc__ when
>using Cython or Pyrex).

Actually, with Python 2.6 or later, the Pythonic solution is to use
``with``.
-- 
Aahz (a...@pythoncraft.com)           <*>         http://www.pythoncraft.com/

"....Normal is what cuts off your sixth finger and your tail..."  --Siobhan
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to