Default Value

Mark Lawrence breamoreboy at yahoo.co.uk
Sat Jun 22 04:26:12 EDT 2013


On 22/06/2013 02:31, Steven D'Aprano wrote:
> On Sat, 22 Jun 2013 05:07:59 +1000, Chris Angelico wrote:
>
>> Oh! I know. Function argument defaults will now be restricted to
>> int/float/tuple. That would do it, right? Nobody would be bothered by
>> little restrictions like that, would they.
>
> Alas, tuples won't do it. Fortunately, you can include str and bytes
> (unicode and str) and frozenset in the "Good List". Tuples have to go
> into the "Bad List" because, although they themselves are immutable,
> their contents may not be. Imagine the confusion and horror that poor
> developers will experience when they do something like this:
>
> def func(arg, extra=(23, 'foo', [])):
>      [code goes here...]
>      extra[2].append("something")
>      [more code...]
>
>
> and they've now mutated the immutable default!
>
> Thinking about this, I think that the only safe thing to do in Rickython
> 4000 is to prohibit putting mutable objects inside tuples. Putting a list
> or a dict inside a tuple is just a bug waiting to happen!
>

How about naming the fork RickedPython 4000, where ricked is defined 
here http://www.urbandictionary.com/define.php?term=ricked ?

-- 
"Steve is going for the pink ball - and for those of you who are 
watching in black and white, the pink is next to the green." Snooker 
commentator 'Whispering' Ted Lowe.

Mark Lawrence




More information about the Python-list mailing list