On Apr 17, 2014, at 14:53, Oleg Broytman phd@phdru.name wrote:
While I don't think it's a good addition for Python...
On Thu, Apr 17, 2014 at 02:41:56PM -0700, Andrew Barnert abarnert@yahoo.com.dmarc.invalid wrote:
On Apr 17, 2014, at 12:14, "Lucas Malor" 7vsfeu4pxg@snkmail.com wrote:
switch_stmt ::= "switch" switch_expr "case" case_expr ":" suite ("case" | "elcase" case_expr ":" suite)* ["else" ":" suite] switch_expr ::= expression case_expr ::= expression_list
- if case_expr is a tuple, the case suite will be executed if switch_expr is a member of the tuple
So there's no way to switch on a tuple?
A tuple can be a member of a bigger tuple:
(1, 'b') in ((1, 'a'), (1, 'b'), (1, 'a', 'b'))
True
Well, yeah, but if you want to match (1, 'b') you'd have to write case ((1, 'b'),). Which is bad for static cases, and even worse for dynamic ones.