On Fri, 24 Jul 2015 12:01:58 -0400, Neal Becker wrote:
>
> This would work, but is not very elegant. I hope for a better way.
>
> need_cleanup = False try:
>if (condition):
> do_something_needing_cleanup need_cleanup = True
>else:
> do_something_else
>code_executed_uncon
Irmen de Jong wrote:
> On 24-7-2015 16:57, Neal Becker wrote:
>> I have code like:
>>
>> if (condition):
>> do_something_needing_cleanup
>>
>> code_executed_unconditionally
>>
>> > continue or exception>
>>
>> Now, how can I make sure cleanup happens? Actually, what I really would
>> like,
On 24-7-2015 16:57, Neal Becker wrote:
> I have code like:
>
> if (condition):
> do_something_needing_cleanup
>
> code_executed_unconditionally
>
> or exception>
>
> Now, how can I make sure cleanup happens? Actually, what I really would
> like, is:
>
> if (condition):
> do_something_ne
Laura Creighton wrote:
> In a message of Fri, 24 Jul 2015 10:57:30 -0400, Neal Becker writes:
>>I know we have try/finally, but I don't think that helps here, because
>>code_executed_unconditionally couldn't be inside the try. Or am I missing
>>something obvious?
>
> I think so. Either that or
In a message of Fri, 24 Jul 2015 10:57:30 -0400, Neal Becker writes:
>I know we have try/finally, but I don't think that helps here, because
>code_executed_unconditionally couldn't be inside the try. Or am I missing
>something obvious?
I think so. Either that or I am badly misunderstanding you.
I have code like:
if (condition):
do_something_needing_cleanup
code_executed_unconditionally
Now, how can I make sure cleanup happens? Actually, what I really would
like, is:
if (condition):
do_something_needing_cleanup
register_scoped_cleanup (cleanup_fnc)
code_executed_unconditiona