The example I gave earlier is a bit contrived, the real example
fundamentally requires a lambda since I am actually passing in local
variables into the functions the lambda is wrapping. Example:

def MyFunction():
  localVariable = 20
  CreateTask( lambda: SomeOtherFunction( localVariable ) ) # CreateTask
() executes the functor internally

This is more or less like the real scenario I'm working with. There
are other (more personal) reasons why I prefer to avoid 'def' in this
case. I want to keep the functor as central to the code that needs it
as possible to improve code readability.


what about

def MyFunction():
    localVariable = 20
    def wrapper():
        return SomeOtherFunction( localVariable )
    CreateTask( wrapper )

the wrapper is only visible inside MyFunction.

Leonhard
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to