[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-ideas
Subject:    [Python-ideas] Re: Combinations of keywords
From:       MRAB <python () mrabarnett ! plus ! com>
Date:       2023-02-21 18:15:25
Message-ID: c477452b-c533-0485-9b38-30b4a34e7a75 () mrabarnett ! plus ! com
[Download RAW message or body]

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-leave@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/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic