function jumptable idiom
smstNOsmSPAM at bigfoot.com.invalid
Thu Mar 9 18:31:30 CET 2000
> However, that means that all of the functions in the jumptable
> have to assume that they will always get one argument (a
> list). Is there a more natural way to express this?
Try the built-in 'apply' function -- its first arg is a function
name, and its second is a tuple of expressions, eg:
>>> apply(operator.add, (1, 2))
Since you have a list of arguments, you can use the 'tuple'
function to convert it. So for your particular problem you
could use this line:
Hope this is what you were after.
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
More information about the Python-list