[Python-ideas] function defaults and an empty() builtin

Rob Cliffe rob.cliffe at btinternet.com
Sun May 22 13:41:45 CEST 2011



On 21/05/2011 04:19, Steven D'Aprano wrote:
> On Sat, 21 May 2011 05:18:30 am Masklinn wrote:
>> Why special-case empty lists when there is no need to?
> That's a remarkable statement. What is empty() except a special case for
> empty lists?
>
> If you and Jack are serious about this proposal, it would require at
> least two such functions, emptylist and emptydict, not just empty().
> And even if you are right that it solves the problem of default=[]
> (which you aren't, but for the sake of the argument lets pretend), it
> doesn't solve the general issue of mutable defaults.
>
Or all collections could have a "mutable" attribute which, once it has 
been set to False, can never subsequently be reset to True. Then you 
could merge lists and tuples into a single type, ditto sets and frozen 
sets, and you get immutable dictionaries as well.  Plus a considerable 
simplification of the language.




More information about the Python-ideas mailing list