[Python-ideas] __missing__ object/keyword
bruce at leapyear.org
Sat Nov 8 22:20:24 CET 2008
On Sat, Nov 8, 2008 at 12:19 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> Bruce Leban wrote:
>> There *is* one guaranteed way of ensuring that I can't use a variable's
>> value: leaving it unbound.
> This Perl, etc. concept does not fit Python's name-object model. A Python
> mappings and sequences cannot have a key or index without a value. To
> propose otherwise is a major conceptual change.
What I would expect (as a programmer) is that when the parameter is omitted,
the variable is simply not bound and therefore it's omitted from the
mapping, not added to the mapping with a special magic value meaning
However, there is an implementation complication due to the way variable
scoping works in Python: if a variable is left unbound in the function
locals, then references to that variable name would pick up the global if it
exists which would definitely be a surprising result. So I agree that there
would definitely be some complexities to implement this.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas