[Tutor] Are you allowed to shoot camels? [kinda OT]
Bob Gailer
bgailer at alum.rpi.edu
Mon Feb 7 16:09:57 CET 2005
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:bgailer at alum.rpi.edu
303 442 2625 home
720 938 2625 cell
More information about the Tutor
mailing list