Let's Talk About Lambda Functions!

Ian Bicking ianb at colorstudy.com
Wed Jul 31 12:22:44 EDT 2002


On Wed, 2002-07-31 at 08:35, John Roth wrote:
> The issue I was addressing was putting an anonymous function
> (or method) in an expression, without any fancy conditions. In other
> words, putting it where you would normally want to - with lots
> of other code within a class. I wasn't addressing a corner condition.
> 
> When you're writing a method in a class, and you want to
> create an anonymous function within the code of that method,
> how do you tell the compiler that you want a method instead?
> That is the question.

There's no way that I know of, but that shouldn't be a big deal. 
Typically you'll have to use nested scopes (to get self bound implicitly
in the lambda), or pass self in as a default parameter (e.g., lambda x,
self=self: ...)

  Ian






More information about the Python-list mailing list