On Thu, Jul 19, 2018 at 8:40 PM Michael Lee <michael.lee.0...@gmail.com>
wrote:

>
>    1. ...
>
>    2. We can already easily get the same functionality using standard
>    Python. E.g., instead of doing foo?["bar"]?[0]?["baz"], we could do 
> lookup(foo,
>    "bar", 0, "baz") where lookup is a function that looks roughly like
>    this:
>
>        def lookup(item, *parts):
>            for part in parts:
>                if item is None:
>                    return None
>                item = item[parts]
>            return item
>
>
Try/except also looks decent.

    try:
        x = foo['bar'][0]
    except TypeError:
        x = 'default'
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to