2017-11-29 11:14 GMT+03:00 Nick Coghlan <ncogh...@gmail.com>:
> It's OK to say "the use case exists, but I still > don't want that particular syntax for it in Python" (I'm personally > inclined to agree with you on that front). It's not OK to try to claim > there are no use cases where the status quo is awkward enough to > become irritating (since it's an empirically false statement that you > don't need to be making). > If the problem with the proposed syntax, but there are cases for use, it may be worth to bikeshed one more time? 2017-11-29 9:08 GMT+03:00 Steven D'Aprano <st...@pearwood.info>: I'd much prefer to read, write and teach the version with ?? over the > status quo. Since the proposed semantics is more similar to the idea of "or", may be it is better to consider something like: timeout then local_timeout then global_timeout I do not know how much this is a frequent case to be worthy of a keyword. With kind regards, -gdg 2017-11-29 11:14 GMT+03:00 Nick Coghlan <ncogh...@gmail.com>: > On 29 November 2017 at 16:13, David Mertz <me...@gnosis.cx> wrote: > > Strong -1 still from me. Too special case for syntax. Just write a > function > > 'first_non_none()' that can perfectly will handle the need. > > That's the equivalent of SQL's COALESCE, and it's insufficient for the > same reason "and" and "or" are syntax rather than builtins: the > function form doesn't provide short-circuiting behaviour. > > As far as utility goes, I put it in a similar category to matrix > multiplication: if you don't need it, you don't need it, but when you > do need it, you need it a *lot*. > > The use case where these operations come up is when you're working > with partially structured hierarchical data (*cough*JSON*cough*). In > those kinds of structures, None is frequently used as a marker to say > "this entire subtree is missing", and you either want to propagate > that None, or else replace it with something else (and the "something > else" may be a network call to a different service, so you definitely > don't want to do it if you don't need to). > > So I'd remind folks to try to avoid the "I don't need this, so nobody > needs this" mistake. It's OK to say "the use case exists, but I still > don't want that particular syntax for it in Python" (I'm personally > inclined to agree with you on that front). It's not OK to try to claim > there are no use cases where the status quo is awkward enough to > become irritating (since it's an empirically false statement that you > don't need to be making). > > Cheers, > Nick. > > -- > Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/