I guess that's inevitable (given lambda's existence... and human
nature;-) and about on the same plane as another hatefully redundant
construct I find myself having to beat upon over and over in code
reviews:
if expression:
result = True
else:
result = False
return result
vs
On Sat, 3 May 2008 08:27:27 pm Nick Coghlan wrote:
Samuele Pedroni wrote:
I found only an example in my personal recent code:
START = !-- *db-payload-start* --
END = !-- *db-payload-end* --
TITLEPATTERN = lambda s: title%s/title % s
this three are later used in a very few .find()
On Sun, 4 May 2008 01:24:54 am Alex Martelli wrote:
On Fri, May 2, 2008 at 11:32 PM, Mike Klaas [EMAIL PROTECTED]
wrote: ...
Sorry, that was a bad example. It is obviously silly if the
return value of the function is callable.
...and yet it's *exactly* what keeps happening to
Steven D'Aprano steve at pearwood.info writes:
I think you're exaggerating a tad here. Why would you be very confused
when you see TITLEPATTERN() or foo(callback=TITLEPATTERN)? What else
would TITLEPATTERN be but a callable when it's being used as a
callable?
The real problem is this
Terry Reedy wrote:
Some people write
somename = lambda args: expression
instead of the more obvious (to most people) and, dare I say, standard
def somename(args): return expression
Visually I find the second form very ugly.
The colon indicates to me that a new line is expected, and
[Terry Reedy]
Some people write
somename = lambda args: expression
instead of the more obvious (to most people) and, dare I say, standard
def somename(args): return expression
Though def-statements are usually the best way to go,
there are some reasonable cases where the first form reads
On Sun, May 4, 2008 at 3:31 AM, Raymond Hettinger [EMAIL PROTECTED] wrote:
...
for k,g in groupby(iterable, key=lambda r: (r[0].lower(), r[5].lower())):
...
lastname_firstname = lambda r: (r[0].lower(), r[5].lower())
for k, g in groupby(iterable, key=lastname_firstname): ...
That
Raymond Hettinger wrote:
lastname_firstname = lambda r: (r[0].lower(), r[5].lower())
for k, g in groupby(iterable, key=lastname_firstname): ...
That transformation adds clarity. Going further and creating a separate
def-statement outside the current function would just move the relevant
On 2-May-08, at 11:23 PM, Scott David Daniels wrote:
Mike Klaas wrote:
... A common pattern for me is to replace an instances method with a
lambda to add monitoring hooks or disable certain functionality:
inst.get_foo = lambda: FakeFoo()
This is not replacable in one line with a def (or
On Fri, 2 May 2008 19:03:55 -0400
Terry Reedy [EMAIL PROTECTED] wrote:
Some people write
somename = lambda args: expression
instead of the more obvious (to most people) and, dare I say, standard
def somename(args): return expression
[...]
There are currently uses of named lambdas at
Terry Reedy wrote:
Some people write
somename = lambda args: expression
instead of the more obvious (to most people) and, dare I say, standard
def somename(args): return expression
The difference in the result (the only one I know of) is that the code and
function objects get the
Alex Martelli wrote:
On Fri, May 2, 2008 at 4:11 PM, Jesse Noller [EMAIL PROTECTED] wrote:
+1 from me
+2 from me -- of all abuses of lambdas, this one's the worst.
What Alex said :)
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
Samuele Pedroni wrote:
I found only an example in my personal recent code:
START = !-- *db-payload-start* --
END = !-- *db-payload-end* --
TITLEPATTERN = lambda s: title%s/title % s
this three are later used in a very few .find() and .replace()
expressions in the same module. I suppose
Nick Coghlan wrote:
Samuele Pedroni wrote:
I found only an example in my personal recent code:
START = !-- *db-payload-start* --
END = !-- *db-payload-end* --
TITLEPATTERN = lambda s: title%s/title % s
this three are later used in a very few .find() and .replace()
expressions in the same
Steven schrieb:
Speaking as one of those some people, my position is that functions
created with lambda are first-class objects the same as everything else
in Python, and a rule that says You must not assign a lambda to a
name, ever would be a terrible rule.
PEP 8 is for the standard library
Christian Heimes schrieb:
Steven schrieb:
Speaking as one of those some people, my position is that functions
created with lambda are first-class objects the same as everything else
in Python, and a rule that says You must not assign a lambda to a
name, ever would be a terrible rule.
PEP 8 is
On Fri, May 2, 2008 at 11:32 PM, Mike Klaas [EMAIL PROTECTED] wrote:
...
Sorry, that was a bad example. It is obviously silly if the return value
of the function is callable.
...and yet it's *exactly* what keeps happening to lambda-happy
programmers -- in production code as well as
Samuele Pedroni wrote:
I found only an example in my personal recent code:
START = !-- *db-payload-start* --
END = !-- *db-payload-end* --
TITLEPATTERN = lambda s: title%s/title % s
this three are later used in a very few .find() and .replace()
expressions in the same module. I suppose my
On Sat, 3 May 2008, Brett Cannon wrote:
On Sat, May 3, 2008 at 1:03 AM, Terry Reedy [EMAIL PROTECTED] wrote:
Some people write
somename = lambda args: expression
instead of the more obvious (to most people) and, dare I say, standard
def somename(args): return expression
The
Agreed, I tend to pick these out of style reviews at Google.
On Fri, May 2, 2008 at 4:03 PM, Terry Reedy [EMAIL PROTECTED] wrote:
Some people write
somename = lambda args: expression
instead of the more obvious (to most people) and, dare I say, standard
def somename(args): return
+1 from me
On May 2, 2008, at 7:03 PM, Terry Reedy [EMAIL PROTECTED] wrote:
Some people write
somename = lambda args: expression
instead of the more obvious (to most people) and, dare I say, standard
def somename(args): return expression
The difference in the result (the only one I know
Some people write
somename = lambda args: expression
instead of the more obvious (to most people) and, dare I say, standard
def somename(args): return expression
The difference in the result (the only one I know of) is that the code and
function objects get the generic name 'lambda'
On 2-May-08, at 4:03 PM, Terry Reedy wrote:
Some people write
somename = lambda args: expression
instead of the more obvious (to most people) and, dare I say, standard
def somename(args): return expression
The difference in the result (the only one I know of) is that the
code and
+1
For what it's worth from a newbie
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
24 matches
Mail list logo