[Uncle T]
> One language feature conspicuous by absence in newbie
> confusions was, consistently, assignment expressions. Read any book
> or tutorial for such a language, and you'll find very little space
> devoted to them too.
Well, you have an entire code style built around this feature called Yoda
conditions. You teach people on Day 1 to never ever confuse == with =. Some
compilers even warn about this because so many people did it wrong.
> What's to learn? If they understand "binding a name" _at all_ (which
> they must to even begin to write a non-trivial program), the only
> twist is that a binding expression returns the value being bound.
Ha, not in Python! Here we have *different syntax* for assignments in
expressions. Well, you can also use it as a statement. But don't! We have a
better one for that. And that one supports type annotations, can unpack and
assign to many targets at the same time, and can even increment, multiply and
so on, at once. But the other one can't.
So only use the Pascal one in expressions. But don't forget parentheses,
otherwise it will bind the thing you probably didn't want anyway.
>> To my eyes, the examples give ample opportunity for being
>> misunderstood and will create a need to puzzle-out the intended semantics.
>
> Some do, many don't.
As soon as we have to wrap a part of an expression in parentheses, parsing the
entire thing becomes more complex. Often enough it will cause the expression to
exceed whatever line length limit the codebase pledged not to exceed, causing
one line to become three. And again, making it trickier for a regular Łukasz to
understand what's going on.
-- Ł
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com