Alan,
That's actually worse than you might think. Try this:
var = 'd'
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')()
And what you get is:
<function p at 0x009BDFB0>
That's hardly a pass :-)
Jeff
-----Original Message-----
From: Alan Gauld [mailto:[EMAIL PROTECTED]
Sent: Monday, February 07, 2005 3:06 PM
To: Smith, Jeff; Bob Gailer; [email protected]
Subject: Re: [Tutor] Are you allowed to shoot camels? [kinda OT]
> 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.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor