[omaha] with blocks and conditions
Jeff Hinrichs
jeffh at delasco.com
Sat Nov 15 05:31:43 CET 2014
does do_stuff() do anything with the file? or the file contents? Seems
like things are switch-a-roo'd.
Maybe do_stuff() does too much?
if condition_is true:
file = blah
else:
file = None
do_stuff(file=file, ...)
Even that seems ugly. Can you flesh out a slightly more detailed
-Jeff
On Fri, Nov 14, 2014 at 3:29 PM, Aaron Keck <keckbug at gmail.com> wrote:
> 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
> _______________________________________________
> Omaha Python Users Group mailing list
> Omaha at python.org
> https://mail.python.org/mailman/listinfo/omaha
> http://www.OmahaPython.org
>
More information about the Omaha
mailing list