Steven D'Aprano writes:
I'm not sure that I understand your example here. Or rather, I understand your example, I don't understand why you think it disputes my comment above. Your example uses the list repetition operator, which returns a list; it is neither something that returns an arbitrary value, nor a method that operates in place.
My point is that given that the operation involves a non-list and the operation is in fact defined to be commutative, it *is* something that returns an arbitrary value -- if your frame of reference is a binary operation on a set, which involves two operands and a result, all members of the same set.
Here are two hypothetical examples:
[...]
It's not clear to me that either of these would make good examples of augmented assignment:
Sure, but that's not the way this works, picking out obviously bad examples. You need to do some work to make the plausible. In the case of the list index, renaming the assignment target: ndx = [10, 20, 30, 40, 50] ndx .= index(40) To me that looks like a statement-oriented version of the fluent style. For the "returning None" example, using .= with a method that is *defined* to return None is pretty silly. But consider a binary tree where the attributes Node.left and Node.right are None if no subtree is attached: # 1776, not Hamilton def cool_cool_conservative_men(federalist_heap): judge = federalist_heap while judge: appoint_justice(judge) judge .= right Note that this example could be modified to use a null Node (ie, bool(null_node) == False) instead of None, in which case it could be in-place. Are those styles Pythonic? Probably not. Are they even practically useful? I'm not sure. But they're much more the kind of example we need to look at to understand this proposal.