This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients martin.panter, vstinner
Date 2016-03-25.23:11:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1458947505.8.0.0973889661243.issue26612@psf.upfronthosting.co.za>
In-reply-to
Content
"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.
History
Date User Action Args
2016-03-25 23:11:45vstinnersetrecipients: + vstinner, martin.panter
2016-03-25 23:11:45vstinnersetmessageid: <1458947505.8.0.0973889661243.issue26612@psf.upfronthosting.co.za>
2016-03-25 23:11:45vstinnerlinkissue26612 messages
2016-03-25 23:11:45vstinnercreate