A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-September/104260.html below:

[Python-Dev] Resource leaks warnings

[Python-Dev] Resource leaks warnings [Python-Dev] Resource leaks warningsHrvoje Niksic hrvoje.niksic at avl.com
Wed Sep 29 15:16:14 CEST 2010
On 09/29/2010 02:42 PM, Antoine Pitrou wrote:
>>  It seems like a slippery slope. Sometimes you really don't care like
>>  when you're just hacking together a quick script.
>
> Isn't the "with" statement appropriate in these cases?

A hacked-together quick script might contain code like:

parse(open(bla).read())

Compared to this, "with" adds a new indentation level and a new 
variable, while breaking the flow of the code:

with open(bla) as foo:
     contents = foo.read()
parse(contents)

People used to writing production code under stringent guidelines 
(introduced for good reason) will probably not be sympathetic to 
quick-hack usage patterns, but Python is used on both sides of the fence.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4