On 2023-02-21 11:26, Steven D'Aprano wrote:
[snip]
If your code blocks are a single statement, you can write:
try: import windows_module
except ImportError: import unix_module
but most people will say that is ugly and be spread out:
try:
import windows_module
except ImportError:
import unix_module
I can think of one use-case.
Suppose this:
try:
import windows_module as module
except ImportError:
import unix_module as module
could be shortened to this:
import windows_module else unix_module as module
Not that I'm in favour of it, because it occurs too rarely to be worth a
special syntax.
[snip]
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/GUFWKK5B2MS46GUJY3P4PUDO3N2FKBWY/
Code of Conduct: http://python.org/psf/codeofconduct/