[Python-ideas] Null coalescing operator

Random832 random832 at fastmail.com
Thu Oct 27 12:41:21 EDT 2016


On Thu, Oct 27, 2016, at 11:27, Joonas Liik wrote:
> perhaps just having a utility function can get us some of the way there..
> 
> #may error
> r = a.b.x.z
> 
> # will default to None
> r = a?.b?.x?.z

If a.b can't or shouldn't be None, this should be a?.b.x.z

I'm not certain how your utility function is supposed to differentiate
this case, or handle subscripts or method calls.

> r = get_null_aware(a, "b.x.z") # long but no new syntax, can be
> implemented today.


More information about the Python-ideas mailing list