[omaha] with blocks and conditions

Aaron Keck keckbug at gmail.com
Fri Nov 14 22:29:11 CET 2014


I've found myself trying to find a cleaner way of doing this:

if *condition_is_true*:
    with *file* as *fp:*
*        do_stuff()*
else:
*    do_stuff()*


Is there a reasonable way to wrap some code using *with* but only in
certain circumstances? Most of the scenarios I've bumped up against have
had some sort of alternate solution that works well, but I'm still curious.


-Aaron


More information about the Omaha mailing list