[Python-ideas] Optional parameters without default value

Paul Moore p.f.moore at gmail.com
Thu Mar 2 09:33:57 EST 2017


On 2 March 2017 at 14:24, Steven D'Aprano <steve at pearwood.info> wrote:
> I like this! If the caller doesn't provide a value, the parameter
> remains unbound and any attempt to look it up will give a NameError or
> UnboundLocalError.

Hmm. But those exceptions currently indicate with almost 100%
certainty, a programming error (usually a mis-spelled name or a
control flow error). The proposal makes them a normal runtime
behaviour, in certain circumstances. What would happen if you
mis-spelled the name of the optional parameter? You'd get a NameError
from using the wrong name, rather than from the user not supplying a
value.

I don't think re-using NameError is a good idea here.
Paul


More information about the Python-ideas mailing list