
On Mon, Sep 28, 2015 at 1:15 PM, Donald Stufft <donald@stufft.io> wrote:
The ? Modifying additional attribute accesses beyond just the immediate one bothers me too and feels more ruby than python to me.
Really? Have you thought about it? Suppose I have an object post which may be None or something with a tag attribute which should be a string. And suppose I want to get the lowercased tag, if the object exists, else None. This seems a perfect use case for writing post?.tag.lower() -- this signifies that post may be None but if it exists, post.tag is not expected to be None. So basically I want the equivalent of (post.tag.lower() if post is not None else None). But if post?.tag.lower() were interpreted strictly as (post?.tag).lower(), then I would have to write post?.tag?.lower?(), which is an abomination. OTOH if post?.tag.lower() automatically meant post?.tag?.lower?() then I would silently get no error when post exists but post.tag is None (which in this example is an error). -- --Guido van Rossum (python.org/~guido)