[Python-ideas] switch statement as context manager?
Greg Ewing
greg.ewing at canterbury.ac.nz
Tue Feb 11 23:22:56 CET 2014
Skip Montanaro wrote:
> On Tue, Feb 11, 2014 at 10:58 AM, Philipp A. <flying-sheep at web.de> wrote:
>
>>the problem of a real switch statement is apparently that there’s no good
>>syntax
Last time this was discussed at length, the main sticking
point seemed to be that people generally expect a switch
statement to be implemented by something more efficient
than a series of if-tests. But that's extremely difficult
to do in Python except when all of the case values are
literals, which is a very special situation.
So in general, any switch statement in Python would just
be pure syntactic sugar for an if-else chain, and that
doesn't seem to be considered enough of an advantage to
bother with.
--
Greg
More information about the Python-ideas
mailing list