STINNER Victor added the comment:

"try: ... finally: s.close()" are "with s: ..." do the same thing, but I prefer 
"with" (context-manager). IMO it's more "pythonic". I prefer to see the 
"cleanup block" at the beginning, rather than at the end.

> My point about Python 2 was that this might add an annoying difference 
> between the two branches. Even if you don’t apply this to Py 2, the next 
> person adding or updating a test might be inclined to do it.

Well, there are 3 choices:

(1) Do nothing. The code rotten slowly (technical debt)
(2) Modify all actively development branches (2.7, 3.5, default)
(3) Only modify Python 3.6

Mofiying all branches means taking the (low) risk of introducing regressions. 
IMHO regressions occur, all the time.

I prefer the option (3) because it allows to enhance the code without taking 
any risk on regression.

Yeah, the code diverge, it's a natural fact.

Then you write that my changes replacing try/finally with "with" are not worth. 
Well, maybe you are true. Since 5 years, I convert all the code to "with" 
because I really like context managers. IMHO they make the code stronger and 
easier to read.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26612>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to