
On Mon, Oct 25, 2021 at 11:26 PM Chris Angelico <rosuav@gmail.com> wrote:
On Mon, Oct 25, 2021 at 11:20 PM Marc-Andre Lemburg <mal@egenix.com> wrote:
So whenever new syntax is discussed, I think it's important to look at it from the perspective of a user who hasn't seen it before (could be a programmer new to Python or one who has not worked with the new feature before).
I actually have a plan for that exact perspective. Was going to arrange things tonight, but it may have to wait for later in the week.
This is only one data point, so don't take this TOO strongly, but I spoke with one of my brothers about his expectations. Walked through some things, led him up against the problem, and watched him try to make sense of things. Here's what I learned: 0) When led to the basic problem of "make the default be a new empty list", he didn't stumble on the standard "=None" idiom, so this proposal has definite value. 1) Pure left-to-right evaluation makes more sense than multi-stage evaluation 2) He expected failed forward references to look to the enclosing scope, but on seeing that that isn't what Python does, expected UnboundLocalError 3) To him, it's still basically an argument default value, so all syntax ideas that he came up with were small changes to the "=" sign, rather than being keywords or function-like constructs 5) It's really REALLY hard to devise examples of APIs that logically would want out-of-order referencing, so it doesn't really even matter that much 6) A full understanding of the exact semantics of Python argument passing is (a) not as common as you might think, and (b) not actually even necessary to most programmers One small additional contribution was this syntax: def spam(foo=<expr>): I'm not sure whether it's worth adding to the list, but it's another idea. If anyone else has friends or family who know a bit of Python, would love to hear other people's viewpoints. ChrisA