Death to tuples!

Mike Meyer mwm at mired.org
Fri Dec 2 12:13:55 EST 2005


Antoon Pardon <apardon at forel.vub.ac.be> writes:
>>> Well there are two possibilities I can think of:
>>>
>>> 1)
>>>   arg_default = ...
>>>   def f(arg = arg_default):
>>>      ...
>>
>> Yuch. Mostly because it doesn't work:
>>
>> arg_default = ...
>> def f(arg = arg_default):
>> ...
>>
>> arg_default = ...
>> def g(arg = arg_default):
>>
>> That one looks like an accident waiting to happen.
> It's not because accidents can happen, that it doesn't work.
> IMO that accidents can happen here is because python
> doesn't allow a name to be marked as a constant or unreboundable.

Loets of "accidents" could be fixed if Python marked names in various
ways: with a type, or as only being visible to certain other types, or
whatever. A change that requires such a construct in order to be
usable probably needs rethinking.

Even if that weren't a problem, this would still require introducting
a new variable into the global namespace for every such
argument. Unlike other similar constructs, you *can't* clean them up,
because the whole point is that they be around later.

The decorator was an indication of a possible solution. I know it
fails in some cases, and it probably fails in others as well.

      <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list