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

Steve Holden steve at holdenweb.com
Thu Dec 8 04:59:46 EST 2005


Steven D'Aprano wrote:
> On Wed, 07 Dec 2005 10:59:09 +0100, Sybren Stuvel wrote:
[...]
> But then you have all these small functions lying around in your module.
> If you intend to use them multiple times, then obviously you should
> keep them. But if they are intended to be used once, and once only, it
> seems bad to leave them there tempting fate.
> 
> E.g. you have some code that uses a large lookup table. Rather than type
> the lookup table in by hand, you write a function which creates all or
> part of it. Once the lookup table is created, you shouldn't use that
> function again -- at best it is just sitting around like a third wheel,
> at worst it might have side-effects you don't want. So I del the function.
> 
> The logic seems impeccable to me, and yet somehow deleting them after they
> are used feels ... not so much wrong, as just ... worthy of a
> head-scratching. 
> 
> 
In cases like this you would be like the law, and not concern yourself 
with trifles. In the majority of cases it costs you more to think about 
this and do the typing than it saves.

I've no objection to the practice when it makes a difference, but ask 
yourself how many bytes you are saving by allowing the code for that 
function to be collected.

Having said this, neither do I have any objection to your continuing to 
anally tidy up your namespace, but then I'm a slob whose partner is a 
neat freak, so I'm well used to accommodating the unnecessary.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list