it is not worth changing Python over. I agreed here, is doesn't make that difference
Em qui, 18 de jun de 2020 14:25, Christopher Barker <python...@gmail.com> escreveu: > On Thu, Jun 18, 2020 at 10:00 AM Daniel. <danielhi...@gmail.com> wrote: > >> def foo(): >> if a: >> return >> if B: >> return >> if C: >> return >> >> do_stuff() >> >> >> Vs >> >> def foo(): >> return if a >> return if B >> return if C >> do_stuff >> >> The second is much more compact >> > > is compact good ?!? > > >> if A: return >> >> Well, I'm strongly against these non-indented blocks in python >> > > But why? you nseem to theink the more compact Ruby version is better, so > why not the more compact Python version -- the only difference is a colon, > and the order: > > def foo(): > if a: return > if B: return > if C: return > > which is equally compact, and puts the "meat" of the code up front, which > feels more clear and obvious to me. > > I do use this form myself, in just this situation, where there are > multiple cases, and it is compact enough that the return doesn't get lost. > That is, I would not do: > > if ( A and B) or (this > that) and (something in everything): return > > in that case, the return gets lost out at the end -- even if you don't go > beyond 72 chars. > > anyway, even if it's a slight be more readable to some, it is not worth > changing Python over. > > -CHB > > > > > > >> Em qui, 18 de jun de 2020 13:36, Barry Scott <ba...@barrys-emacs.org> >> escreveu: >> >>> >>> >>> On 18 Jun 2020, at 13:30, Daniel. <danielhi...@gmail.com> wrote: >>> >>> I love the do_stuff if cond syntax in Ruby and in perl. It's very >>> natural to real, much more to follow than if cond: do_stuff >>> >>> >>> I on the other hand hate that syntax and find it harder to read. >>> >>> Why put the code out of sequence? >>> >>> if read_this_1st: read_this_2nd() >>> >>> vs. this that I think of as out of sequence order >>> >>> read_this_2nd() if not read_this_1st >>> >>> Barry >>> >>> >>> >>> But still I don't think that it is enough to demand a language change. >>> >>> Something near this is to have a default of none for >>> >>> A if B else None >>> >>> So we can ommit the else None part, but this goes against the explicit >>> is better than implicit >>> >>> Em qua, 17 de jun de 2020 07:42, Paul Moore <p.f.mo...@gmail.com> >>> escreveu: >>> >>>> On Wed, 17 Jun 2020 at 10:44, artem6191 <artem129...@gmail.com> wrote: >>>> > >>>> > So yeah, we can "if <expression>: return", but why not? >>>> >>>> That's the wrong question. The correct question is "why is this >>>> needed, and is the need sufficiently pressing to justify the change to >>>> the language?" >>>> >>>> You're talking about allowing "return EXPR if CONDITION" as an exact >>>> equivalent of "if CONDITION: return EXPR". There isn't even a benefit >>>> of "it saves a line of code", so it's very hard to see a >>>> justification. >>>> >>>> Paul >>>> _______________________________________________ >>>> 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/PHB2VWU3J2YAGCWZR5N5N2BAGPFBQMF4/ >>>> Code of Conduct: http://python.org/psf/codeofconduct/ >>>> >>> _______________________________________________ >>> 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/WEK6CTGJGEBD6ROG5BASTJ6C43OKBTRE/ >>> Code of Conduct: http://python.org/psf/codeofconduct/ >>> >>> >>> _______________________________________________ >> 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/3QILG6Z6V2TGDIRGQFVGTOWGNO4R7KWR/ >> Code of Conduct: http://python.org/psf/codeofconduct/ >> > > > -- > Christopher Barker, PhD > > Python Language Consulting > - Teaching > - Scientific Software Development > - Desktop GUI and Web Development > - wxPython, numpy, scipy, Cython >
_______________________________________________ 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/QIQEASAKJEJRPZPOXY2CWH6OVI6MCXHG/ Code of Conduct: http://python.org/psf/codeofconduct/