Message195222
I think you make a good case, but I already tried and failed to convince Guido of this in PEP 377 (see http://www.python.org/dev/peps/pep-0377/#rationale-for-change)
More importantly, see his quoted concerns in http://mail.python.org/pipermail/python-dev/2009-March/087263.html
While you have come up with a much simpler *implementation* for PEP 377, which imposes no additional overhead in the typical case (unlike my implementation, which predated the SETUP_WITH opcode and avoided introducing one, which required wrapping every __enter__ call in a separate try/except block), it still adds a new builtin exception type, and I thing needs a new builtin constant as well.
The latter comes in because I think the bound variable name still needs to be set to something, and rather than abusing any existing constant, I think a new SkipWith constant for both "don't call enter/exit" and "with statement body was skipped" would actually be clearer.
I actually think explaining a custom exception and constant is less of a burden than explaining why factoring out certain constructs with @contextmanager and yield doesn't work properly (that's why I wrote PEP 377 in the first place), but Guido is the one that ultimately needs to be convinced of the gain. |
|
Date |
User |
Action |
Args |
2013-08-14 21:48:32 | ncoghlan | set | recipients:
+ ncoghlan, gvanrossum, barry, kristjan.jonsson, r.david.murray, eric.snow |
2013-08-14 21:48:32 | ncoghlan | set | messageid: <1376516912.61.0.506554963898.issue18677@psf.upfronthosting.co.za> |
2013-08-14 21:48:32 | ncoghlan | link | issue18677 messages |
2013-08-14 21:48:32 | ncoghlan | create | |
|