> > The two statements you wrote are not the same. The first statement will > error out if person is None.
That's my bad. I was copying off of an erroneous example. Thanks for correcting me. The proposed None-aware operators are specifically designed to handle > variables that may be None. > Yes, I think the syntax that you've landed on is confusing enough that it opens the door to more errors than it closes. Just reading "(a?.b ?? c).d?.e" and "await a?.b(c).d?[e]" On Wed, Jul 25, 2018 at 6:06 PM, Nicholas Chammas < nicholas.cham...@gmail.com> wrote: > On Wed, Jul 25, 2018 at 6:11 PM Abe Dillon <abedil...@gmail.com> wrote: > >> The problem here is not whether it's explicit. It's about Readability and >> conciseness. Using symbols in place of words almost always harms >> readability in favor of conciseness. >> >> value = person.name if person.name else person >> >> almost reads like english (aside from being a weird and totally uncommon >> use case) >> >> value = person?.name >> >> Is a huge step towards the concise illegible soup of symbols that Perl is >> famous for. It's a huge No from me. >> > > The two statements you wrote are not the same. The first statement will > error out if person is None. The proposed None-aware operators are > specifically designed to handle variables that may be None. > > The first statement should instead read: > > value = person.name if person is not None else person > > That's what `value = person?.name` means. > > As others have pointed out, I suppose the fact that multiple people have > messed up the meaning of the proposed operators is concerning. Perhaps the > PEP could be improved by adding some dead simple examples of each operator > and an equivalent statement that doesn't use the operator, to better > illustrate their meaning. But I gather that will do little in the way of > addressing some of the stronger objections raised here. >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/