[Tutor] Are you allowed to shoot camels? [kinda OT]

Alan Gauld alan.gauld at freenet.co.uk
Mon Feb 7 21:06:28 CET 2005


> That's kinda what I thought but a couple of people suggested 
> that I used lambdas to make it clearer 

I suggested that if we had proper lambdas we could use 'em...

But of course you can still use lambdas just put the print 
at the client side:

def p(): pass
ftable = { 'a' : lambda: 'a',
           'b' : lambda: 'b or c',
           'c' : lambda: 'b or c',
           'd' : lambda: p}
print ftable.get(var, lambda: 'default case')()

But I still had to use a def for the pass... :-(

Alan G.



More information about the Tutor mailing list