[Python-ideas] Block-Scoped Exception Handlers
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri May 6 21:41:24 EDT 2016
Kyle Lahnakoski wrote:
> ________try:
> ____________if null_data[byte] >> bit & 1:
> ________________return Null
> ________except IndexError:
> ____________print(null_data)
> ____________print(index)
> ____________print(byte, bit)
> ____________print(len(self._data), self._data)
> ____________print(null_def)
> ____________print(null_data)
> ____________raise
Using a suitably-defined context manager, it should be
possible to write that something like this:
with Activity("Getting a bit", lambda: (null_data, index,
(byte, bit), (len(self._data), self._data), null_def, null_data):
if null_data[byte] >> bit & 1:
return Null
--
Greg
More information about the Python-ideas
mailing list