[Python-ideas] switch statement as context manager?

Ryan Gonzalez rymg19 at gmail.com
Mon Feb 10 17:43:08 CET 2014


Probably not. When I wrote PyExt, it was with the sole idea that you can
get around stuff by abusing Python's reflection mechanisms. Even the code
for the switch statement is very hackish. I don't quite think that belongs
in stdlib.


On Mon, Feb 10, 2014 at 8:31 AM, Sturla Molden <sturla.molden at gmail.com>wrote:

> I've noticed that PyExt has a switch statement implemented as a context
> manager.
>
> with switch(foobar):
>     if case(1): pass
>     if case(2): pass
>
> Would this be something to consider for the standard lib, e.g. contextlib?
>
> Sturla
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



-- 
Ryan
If anybody ever asks me why I prefer C++ to C, my answer will be simple:
"It's becauseslejfp23(@#Q*(E*EIdc-SEGFAULT. Wait, I don't think that was
nul-terminated."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140210/cad4e3a7/attachment.html>


More information about the Python-ideas mailing list