Why anonymity? [was Re: map/filter/reduce/lambda opinions and background unscientific mini-survey]

2005-07-07 Thread Steven D'Aprano
Steven Bethard wrote: If you're really afraid of two lines, write it as: def r(): randint(1, 100) This is definitely a bad case for an anonymous function because it's not anonymous! You give it a name, r. This is something I've never understood. Why is it bad form to assign an

Re: Why anonymity? [was Re: map/filter/reduce/lambda opinions and background unscientific mini-survey]

2005-07-07 Thread Duncan Booth
Steven D'Aprano wrote: This is something I've never understood. Why is it bad form to assign an anonymous function (an object) to a name? Because it obfuscates your code for no benefit. You should avoid making it hard for others to read your code (and 'others' includes yourself in the

Re: Why anonymity? [was Re: map/filter/reduce/lambda opinions and background unscientific mini-survey]

2005-07-07 Thread Steven D'Aprano
On Thu, 07 Jul 2005 09:36:24 +, Duncan Booth wrote: Steven D'Aprano wrote: This is something I've never understood. Why is it bad form to assign an anonymous function (an object) to a name? Because it obfuscates your code for no benefit. You should avoid making it hard for others

Re: Why anonymity? [was Re: map/filter/reduce/lambda opinions and background unscientific mini-survey]

2005-07-07 Thread Bengt Richter
On 7 Jul 2005 15:46:23 GMT, Duncan Booth [EMAIL PROTECTED] wrote: Steven D'Aprano wrote: Put it this way: whenever I see a two-line def as above, I can't help feeling that it is a waste of a def. (Somebody went to all the trouble to define a function for *that*?) Yet I would never think the

Re: Why anonymity? [was Re: map/filter/reduce/lambda opinions and background unscientific mini-survey]

2005-07-07 Thread Ron Adam
Steven D'Aprano wrote: On Thu, 07 Jul 2005 09:36:24 +, Duncan Booth wrote: Steven D'Aprano wrote: This is something I've never understood. Why is it bad form to assign an anonymous function (an object) to a name? Because it obfuscates your code for no benefit. You should avoid making

Re: Why anonymity? [was Re: map/filter/reduce/lambda opinions and background unscientific mini-survey]

2005-07-07 Thread Daniel Schüle
Am I just weird? I feel the same way about where to use lambda's and where *not* I come from C and C++ background and defining a function at the top level (no nested functions) would always require good reasons function name has to be remembered, to put it in other words it has to be added in