[Python-ideas] except expression
Steven D'Aprano
steve at pearwood.info
Fri Feb 21 00:57:04 CET 2014
On Wed, Feb 19, 2014 at 05:34:26PM -0800, Andrew Barnert wrote:
> So, while there's no need to actually ban "os.unlink(some_file) except
> OSError: None", it doesn't make a good argument for the PEP.
What he said.
It's actually a bad argument for the PEP, as it's a misuse of the
expression form. A slightly less-worse example might be:
errors = filter(bool, [os.unlink(file) except OSError as err:
err.args[0] for file in files])
except we're deferring the "as err" part :-)
--
Steven
More information about the Python-ideas
mailing list