*sorry, cat hit "send"... Just reading those examples made me want to cry and go hide in a dark dark cave and never come out. I'm sure using actual variable names would help a bit, but not much.
As for the non-english nature of: value = person.name I highly disagree with the argument that since that is a step removed from natural language readability that: value = person?.name Should be considered fair game. Nor do I buy the "other languages do it" argument. Some of the syntax of Python is based on familiar patterns in other languages (like '.' access) some of it is based on common math (e.g. "=", "+", etc.) which is also taught in grade school. Some of the patterns borrowed from other languages were a mistake and considered cruft. Some of that cruft was scraped off in the 2to3 migration. Maybe "." should have been apostrophe "s" all along. Maybe lambda should have been 'make_function'. That's not what we're here to discuss. A lot of languages have a ternary operator (x ? y : z). Python wisely used words instead of symbols and now many students don't even have to crack a book to decipher Python's ternary operator. Adding crap to a language is easy. Removing it is damn near impossible. You have to have extremely good reasons to add new syntax and I don't have to defend any of Python's warts to justify rejecting yours. On Wed, Jul 25, 2018 at 6:15 PM, Abe Dillon <abedil...@gmail.com> wrote: > 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/