Path: csiph.com!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc Subject: Re: Command Languages Versus Programming Languages Date: Wed, 03 Apr 2024 09:00:25 -0700 Organization: None to speak of Lines: 34 Message-ID: <87plv6jv1i.fsf@nosuchdomain.example.com> References: <20240329084454.0000090f@gmail.com> <20240329101248.556@kylheku.com> <20240329104716.777@kylheku.com> <20240330112105.553@kylheku.com> <87r0fp8lab.fsf@tudado.org> <87wmpg7gpg.fsf@tudado.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 03 Apr 2024 16:00:34 +0200 (CEST) Injection-Info: dont-email.me; posting-host="a67faaad1a2f17d94ae762a9e9871bf2"; logging-data="35184"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+tWxYn4nXgVu9iJxdNr+YE" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:A89/7wvR9zKbeODaOOgvUK4r2mU= sha1:e1DnGyJG214lrbIxruA6I5QgamY= Xref: csiph.com comp.unix.shell:24926 comp.unix.programmer:15673 comp.lang.misc:10347 David Brown writes: > On 03/04/2024 02:23, Lawrence D'Oliveiro wrote: >> On 2 Apr 2024 08:26:14 GMT, Stefan Ram wrote: >> >>> ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted: >>> >>>> def diff( x ): >>>> return 1 if x == 'x' else 0 if type( x )is str else[ 'sum', diff( x[ >>>> 1 ]), diff( x[ 2 ])] >>>> if x[ 0 ]== 'sum' else None >>> >>> Oops! That was one long line starting with "return"; >>> it was wrapped by the newsreader, but is not correct Python anymore >>> when wrapped this way. >> It’s bloody horrible Python even when wrapped correctly. I think >> Python’s version of the conditional expression is a complete >> abortion. > > That's probably the reason almost no one uses it. That post is the > first time I have ever seen conditional expressions outside of a brief > mention in a tutorial on Python conditionals showing how to write > normal conditionals in the language. I think Python stole this one > from Perl. No, Perl's conditional expressions use the same syntax as C's. As for whether Python's conditional expression syntax, it's not clear that (cond ? expr1 : expr2) is better or worse than (expr1 if cond else expr2) (unless you happen to be familiar with one of them). -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Medtronic void Void(void) { Void(); } /* The recursive call of the void */