Re: A replacement for lambda



on 30.07.2005 10:20 Paolino said the following:
why (x**2 with(x))<(x**3 with(x)) is not taken in consideration?

If 'with' must be there (and substitue 'lambda:') then at least the syntax is clear.IMO Ruby syntax is also clear.


I am sorry if this has already been proposed (I am sure it has).

Why not substitue python-lambdas with degenerated generator expressions::

  (lambda x: func(x)) == (func(x) for x)

i.e. a one time callable generator expression (missing the `in` part). The arguments get passed into the generator, I am sure that can be combined with the PEP about passing args and Exceptions into a generator.

.



Relevant Pages

  • Re: Populating a dictionary, fast
    ... code, while correct in intent, does look a bit fishy (missing those ... By "missing those square brackets", what would be a list comprehension ... Enter 'python "generator expression"' into your favourite search ...
    (comp.lang.python)
  • Re: define "generator" (glossary bug?)
    ... >>> and has used instead the definition for 'generator function', ... >>> which term is missing from the glossary. ... America's vaunted "free press" notwithstanding, ... -- Jim Thornton ...
    (comp.lang.python)
  • About 1.8.7 Array#map! without a block
    ... with e.next to change the value, say, multiplying by 2 as on the first ... case and have a array on the end? ... - Why I get a Generator on "a" elements when I just call e.next? ... cause it's what I'm missing to use with next, ...
    (comp.lang.ruby)
  • RE: Simple Recursive Generator Question
    ... but one of the things you're missing is ... The generator saves you having to pass the "index" param recursively. ... > Changing yield to print, shows that the recursion works correctly. ...
    (comp.lang.python)
  • Re: Is there a better/simpler way to filter blank lines?
    ... I must be missing something: ... Using the surrounding parentheses creates a generator object, ... Downside is the increased memory usage and processing time as you dump ... xlines:" operation, it would be faster to use the generator. ...
    (comp.lang.python)