easy question, how to double a variable

Tim Chase python.list at tim.thechases.com
Mon Sep 21 05:04:06 EDT 2009


Steven D'Aprano wrote:
>> Write the definition of a function  twice , that receives an  int
>> parameter and returns an  int that is twice the value of the parameter.
>>
>> how can i do this
> 
> Yes, that certainly is an easy question.
> 
> Here's my solution:
> 
> class MultiplierFactory(object):
[snip a marvel of abstruse code]
> 
> twice = MultiplierFactory(2)()
> 
> It needs some error checking, but otherwise should work.

Tsk...no docstrings?  no unit tests or doctests?  no parameter 
validation?  no copyright notice?  no revision-tracking nor 
authorship comments?  what sort of bad example are you setting 
here?  You want this kid to fail?!  With such poor instruction, 
it's no wonder the economy is going to shambles, the educational 
system is falling apart, there's global warming, terrorism, spam, 
and reality television. Your piteous code make Paris Hilton cry. 
[shakes head in disappointment]

;-)

-tkc








More information about the Python-list mailing list