PEP 312 - Making lambdas implicit worries me, surely it's just the name 'lambda' that is bad...

Alexander Schmolck a.schmolck at gmx.net
Mon Mar 3 13:30:25 EST 2003


Dan Schmidt <dfan at dfan.org> writes:

> I am a big fan of functional programming and I never use lambdas in my
> Python code because they're too ugly looking.  (It's different in Lisp,
> where all the syntax looks the same, but even there I think lambda is
> too verbose - and so does Lisp guru Paul Graham, who's renamed lambda
> to fn in his new Lisp dialect Arc.)  I'd complain more loudly, but I
> think Guido likes the fact that their ugliness dissuades people from
> using them...

If you fancy yourself a subversive (in which case you obviously already use
emacs rather than e.g. idle) try this:

;;Stefan Monnier's hack to make "lambda" display as λ (a greek lambda symbol)

(unless (featurep 'xemacs)
  (defun pretty-lambdas ()
    (font-lock-add-keywords
     nil `(("\\<lambda\\>"
            (0 (progn (compose-region (match-beginning 0) (match-end 0)
                                      ,(make-char 'greek-iso8859-7 107))
                      nil))))))
  (add-hook 'emacs-lisp-mode-hook 'pretty-lambdas)
  (add-hook 'python-mode-hook 'pretty-lambdas)
  (add-hook 'ilisp-mode-hook 'pretty-lambdas))

alex




More information about the Python-list mailing list