Curious assignment behaviour

John Roth johnroth at ameritech.net
Tue Oct 9 11:35:44 EDT 2001


"Richard Brodie" <R.Brodie at rl.ac.uk> wrote in message
news:9psk9s$rbk at newton.cc.rl.ac.uk...
>
> "John Roth" <johnroth at ameritech.net> wrote in message
news:ts3hb2p7dbh7b5 at news.supernews.com...
>
> > > > Pascal uses :=
> > >
> > > Nope. Pascal is like Python, it doesn't have an assignment operator.
> >
> > But it does have a *syntax* that means assignment, just like Python.
> > I believe that is what the poster had in mind.
>
> It's probably true that the use of := for assignment and = for equality is
> less prone to error for those unused to C-like languages. I think it's a
> lost battle though unless we want another controversial language change
> in  Python 3 ;)

It would be controversial only if we wanted to change the statement
assignment operator. That's not going to happen; I would be against it
in any case since = is pretty much the standard, and has been since
Fortran. Pascal (and I belive Algol) is out of the mainstream on this issue.

However, I think := makes a good choice for an expression assignment
operator. It needs to be different from both the statement assignment
operator and the equality operator. It also can't be in use for an
extended assignment.

Any controversy would be over whether we actually should add this
functionality to Python. I could argue that both ways.

John Roth






More information about the Python-list mailing list