[issue15806] Add context manager for the "try: ... except: pass" pattern

Martin v. Löwis report at bugs.python.org
Wed Aug 29 09:51:30 CEST 2012


Martin v. Löwis added the comment:

I think the zipfile example is really a bad example. IMO, it would
best be written as

try:
  return bool(EndRecData(fp))
except IOError:
  return False

i.e. there shouldn't be a pass statement at all in this code, and the if can be dropped whether you use try-except or with.

----------
nosy: +loewis

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15806>
_______________________________________


More information about the Python-bugs-list mailing list