On 28 October 2016 at 14:13, Barry Warsaw <barry@python.org> wrote:
On Oct 27, 2016, at 07:37 PM, Nick Badger wrote:

>The problem with doing that is that it's ambiguous. There's no way of
>telling which attribute is allowed to coalesce.

You could of course support exactly the same syntax being proposed as a
language change, e.g.

    from operator import attrgetter
    r = attrgetter('b?.x?.z')

and then you wouldn't even need the `coalesce` argument.

The main drawback of this type of approach is that code checking tools will hardly ever support checking expressions inside the string like that.  Also, you don't get proper syntax highlighting, code completion, etc.

You can do anything you want by writing another programming language that is passed as string to a function, but that is not the same thing as having a proper syntax, is it?  Just like type annotations with mypy: sure, you can add type annotations in comments, but it's not the same...

--
Gustavo J. A. M. Carneiro
Gambit Research
"The universe is always one step beyond logic." -- Frank Herbert