[Python-Dev] PEP 572: Do we really need a ":" in ":="?
tim.peters at gmail.com
Thu Jul 5 22:57:53 EDT 2018
> > Do we want to protect users who
> > cannot tell = from == so much that we are willing to cause Python to be
> > the first language with two non-interchangeable assignment operators?
Not even close to the first. Go beat us to it -- it has both = and :=
> assignment operators.
> Ocaml also has := for regular assignment and <- for assignment to
> mutable fields.
> Similarly, Haskall has = for assignment definitions and <- for binding
> in monads.
I skipped that part, because nobody actually cares ;-)
But back when I looked at this, R had them all beat, and I never found a
single source that actually managed to list _all_ of R's variations This
source was clearest, but is missing (at least) all the ways to spell all
the variations as function calls too:
There are three different assignment operators: two of them have leftwards
> and rightwards forms.
The operators <- and = assign into the environment in which they are
> evaluated. The operator <- can be used anywhere, whereas the operator = is
> only allowed at the top level (e.g., in the complete expression typed at
> the command prompt) or as one of the subexpressions in a braced list of
The operators <<- and ->> are normally only used in functions, and cause a
> .[click the link if you're still awake]
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev