Default Value

MRAB python at mrabarnett.plus.com
Fri Jun 21 18:49:51 EDT 2013


On 21/06/2013 21:44, Rick Johnson wrote:
> On Friday, June 21, 2013 2:25:49 PM UTC-5, MRAB wrote:
>> On 21/06/2013 19:26, Rick Johnson wrote:
>> > ============================================================
>> >   The Apathetic Approach:
>> > ============================================================
>> > I could just assume that a programmer is responsible for the
>> > code he writes. If he passes mutables into a function as
>> > default arguments, and then mutates the mutable later, too
>> > bad, he'll understand the value of writing solid code after
>> > a few trips to exception Hell.
>> > ============================================================
>> >   The Malevolent Approach (disguised as beneva-loon-icy):
>> > ============================================================
>> > I could use early binding to confuse the hell out of him and
>> > enjoy the laughs with all my ivory tower buddies as he falls
>> > into fits of confusion and rage. Then enjoy again when he
>> > reads the docs. Ahh, the gift that just keeps on giving!
>>
>> How does the "Apathetic Approach" differ from the
>> "Malevolent Approach"?
>
> In the apathetic approach i allow the programmer to be the
> sole proprietor of his own misfortunes. He lives by the
> sword, and thus, he can die by the sword.
>
> Alternatively the malevolent approach injects misfortunes
> for the programmer on the behalf of esoteric rules. In this
> case he will live by sword, and he could die by the sword,
> or he could be unexpectedly blown to pieces by a supersonic
> Howitzer shell.
>
> It's an Explicit death versus an Implicit death; and Explicit
> should ALWAYS win!
>
> The only way to strike a reasonable balance between the
> explicit death and implicit death is to throw up a warning:
>
>   "INCOMING!!!!"
>
> Which in Python would be the "MutableArgumentWarning".
>
> *school-bell*
>
I notice that you've omitted any mention of how you'd know that the
argument was mutable.




More information about the Python-list mailing list