> As an aside, I did try to create a lambda based solution but was unable. > Let me know what's wrong: > > ftable = { 'a' : lambda: print 'a', > SyntaxError: invalid syntax
I did say "if Python had *proper* lambdas..." Unfortunately Python insists on only having *expressions* as lambdas and since print is a command not a function you can't use it in Python lambdas! Dumb or what??! So you are stuck with predefining a bunch of one liner functions and then creating a dictionary or going back to if/elif chains, which is where we came in... :-) HTH, Alan G. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor