[Python-Dev] PEP 572: Do we really need a ":" in ":="?
alexander.belopolsky at gmail.com
Thu Jul 5 22:48:11 EDT 2018
On Thu, Jul 5, 2018 at 10:10 PM Tim Peters <tim.peters at gmail.com> wrote:
> I solved the problem in my own code by using an editor that displays a
> single "=" in C source as a left-arrow graphic (that's one of its
> C-specific display options - again a response to how notorious this
> bug-magnet is). So assignment and equality-testing in C code look
> entirely different to me, regardless of context.
> But to this day, I routinely get a SyntaxError when writing new Python
> code because I _think_ "if x equals y" and _type_ "if x = y:". So I know
> for sure that it's still a typo I'm way too prone to make.
Python really has a strong C legacy and this is the area where I agree that
C designers made a mistake by picking a symmetric symbol (=) for an
asymmetric operation. On top of that, they picked an asymmetric digraph
(!=) for a symmetric operation as well and Python (unfortunately) followed
the crowd and ditched a much better alternative (<>). My only hope is that
Python 4.0 will allow ← to be used in place of either = or :=. :-)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev