1. 5

    The walrus operator is fine (it doesn’t light my fire but it’s not a bad thing).

    I do wish Python would add two operators:

    A None-coalescing operator. You get something like this:

    print("foo = %s" % (foo?"default"))

    And so if foo is None you get the value "default". You can almost do the same thing with or but there are values that are falsey that aren’t None.

    A Smalltalk-like chaining operator:


    That executes the foo, bar, and baz methods on myobject, discarding the return values from foo and bar. That saves you from having to do


    when you don’t care about the returned values.

    Maybe I should write a PEP. :)

    1. 4

      There’s a PEP for the None-coalescing operator, at least - https://www.python.org/dev/peps/pep-0505/

      Well, actually it adds three operators, so that’s exciting. ?? for coalescing, ?. for None-aware attribute access, and ?[] for None-aware indexing.