Bob, Unfortunately, that doesn't do the same thing. In the 'd' case, you get a print rather than a pass for instance. It was also just happenstance that I chose to print on each switch rather than do something like increment a counter.
Jeff -----Original Message----- From: Bob Gailer [mailto:[EMAIL PROTECTED] Sent: Monday, February 07, 2005 10:10 AM To: Smith, Jeff; tutor@python.org Subject: RE: [Tutor] Are you allowed to shoot camels? [kinda OT] At 07:43 AM 2/7/2005, Smith, Jeff wrote: >That's kinda what I thought but a couple of people suggested that I >used lambdas to make it clearer that I figured I was doing something >wrong... Well you can use lambdas. Have them return an expression which you print after retrieving: ftable = { 'a' : lambda: 'a', 'b' : lambda: 'b or c', 'c' : lambda: 'b or c', 'd' : lambda: ''} print ftable.get(var, lambda: 'default case')() But it would be clearer to store just the expressions: ftable = { 'a' : 'a', 'b' : 'b or c', 'c' : 'b or c', 'd' : ''} print ftable.get(var, 'default case') Bob Gailer mailto:[EMAIL PROTECTED] 303 442 2625 home 720 938 2625 cell _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor