what's wrong with "lambda x : print x/60,x%60"

Antoon Pardon apardon at forel.vub.ac.be
Wed Dec 7 04:52:50 EST 2005


Op 2005-12-07, Steven D'Aprano schreef <steve at REMOVETHIScyber.com.au>:
> On Tue, 06 Dec 2005 00:33:17 +0100, Fredrik Lundh wrote:
>
>> Sybren Stuvel wrote:
>> 
>>> def somefunc(x): return x*5
>>>
>>> How is that a multi-line function definition?
>> 
>> but that's namespace pollution! if you do this, nobody will never ever be
>> able to use the name somefunc again! won't somebody please think about
>> the children!
>
> All joking aside, when I have names (temporary variables or scaffolding
> functions) that I need to initialise a module or data structure, but then
> outlive their usefulness, I del the name afterwards. Am I the only one? I
> can't say I've seen anyone else doing that, and it feels icky to me (for
> no reason I can put my finger on) -- what do others think?

Well I don't do it, but it has bothered me. The direction I'm thinking
of right now is doing all such initialisation within an initialisation
function, all temporary variables or scaffolding functions, defined
in that function will disappear automatically when the function has
done its job.

-- 
Antoon Pardon



More information about the Python-list mailing list