Would Anonymous Functions Help in Learning Programming/Python?

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Mon Sep 24 04:07:24 EDT 2007


In message <1190413322.962737.53900 at r29g2000hsg.googlegroups.com>, 
chris.monsanto at gmail.com wrote:

> A question: if you WERE to implement function definitions as normal
> expressions, how would you go about embedding it within an expression?
> 
> x = map(def a:
>             <line of code>
>             <line of code>
>             <line of code>
>         , [1, 2, 3])

Perl can do it just fine:

$x = map
  (
    sub
      {
        ...
      },
    [1, 2, 3]
  );

The fact that Python has difficulties is purely a demonstration of the
limitations of indentation-controlled syntax, not a criticism of the
concept itself.



More information about the Python-list mailing list