functions which take functions
Tim Roberts
timr at probo.com
Thu Apr 12 02:07:37 EDT 2012
Kiuhnm <kiuhnm03.4t.yahoo.it> wrote:
>
>That won't do. A good example is when you pass a function to re.sub, for
>instance.
This is an odd request.
I often pass functions to functions in order to simulate a C switch
statement, such as in a language translator:
commands = {
'add': doAdd,
'subtract' : doSubtract,
'multiply' : doMultiply,
'divide' : doDivide
}
nextCommand = parseCommandLine( line )
invokeCommand( commands[NextCommand] )
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list