zen of Python vs with statement - philosophical pondering
Posted
by
NeuronQ
on Stack Overflow
See other posts from Stack Overflow
or by NeuronQ
Published on 2012-07-07T08:27:42Z
Indexed on
2012/07/07
9:16 UTC
Read the original article
Hit count: 386
I don't intend to simply waste your time, but: has it occurred to you too, while using Python's with
statement that it really is contrary to the 5th line of "The Zen of Python" that goes "Flat is better than nested"? Can any enlightened Python guru share me some of their insights on this?
(I always find that one more level of indentation pops up in my code every time I use with
instead of f.close()
... and it's not like I'm not gonna use try: ... finally: ...
anyways and thus the benefits of with
still elude me, even as I grow to like and understand Python more and more...)
© Stack Overflow or respective owner