[Python-ideas] Re: Combinations of keywords

2023-02-21 Thread MRAB
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

[Python-ideas] Re: Combinations of keywords

2023-02-21 Thread Paul Moore
On Tue, 21 Feb 2023 at 12:44, James Addison via Python-ideas < python-ideas@python.org> wrote: > On Mon, 20 Feb 2023 at 15:03, Otomatyk dupont wrote: > >> #import A_WINDOW_MODULE and import A_UNIX_MODULE if except > > Here's an attempt to rephrase this slightly, with the following ideas in >

[Python-ideas] Re: Combinations of keywords

2023-02-21 Thread James Addison via Python-ideas
On Tue, 21 Feb 2023 at 11:29, Steven D'Aprano wrote: > Trying to squeeze many lines of code into one line is a bad idea. Agreed, in most cases - but there can be (no pun intended.. probably) exceptions to that. if cloudy or raining: print("Bring an umbrella") else: print("Looks fair

[Python-ideas] Re: Combinations of keywords

2023-02-21 Thread Steven D'Aprano
Hello and welcome! Trying to squeeze many lines of code into one line is a bad idea. It makes it hard to read, and will be impossible for Python where statements and expressions are different and must be on separate lines. Extra lines are cheap. Python does not encourage people trying to cram