[Python-ideas] __missing__ object/keyword
Bruce Leban
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.
>
> tjr
>
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
unbound.
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.
--- Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20081108/7809a469/attachment.html>
More information about the Python-ideas
mailing list