I see that there was previously a PEP to allow the with statement to skip the
enclosing block... this was shot down, and I'm trying to think of the most
elegant alternative.
The best I've found is to abuse the for notation:
for _ in cachingcontext(x):
# create cached resources here
# return cached resources
I would have really liked:
with cachingcontext(x):
# create cached resources here
# return cached resources
I'd also like to avoid the following because it is unnecessary boilerplate:
with cachingcontext(x) as skip:
if not skip:
# create cached resources here
# return cached resources
--
http://mail.python.org/mailman/listinfo/python-list