Re: Re: vote on assignments as expressions

Jonathan Gardner <[email protected]>
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
On Monday 28 June 2004 10:49 am, Mark Hahn wrote:
> "Jonathan Gardner" <[email protected]> wrote
> > Besides, it's not really "assignment" anyway. That was the first hard
> > lesson I had to learn in Python.
>
> I'm not sure what you mean.  What we implement would be real assignment,
> which Python doesn't have.  How could you learn that in Python?
>

Compare how C works when you write "a = b" versus Python.

In C, a takes on the value of b. The value is actually copied over. This is 
assignment.

In Python, b doesn't have a "value". It is more of a reference to an object. 
Thus, when you "assign" b to a, you are only pointing a to whatever b was 
pointing at. There is no copying involved. (Perhaps at the C implementation 
level, the pointer to the PyObjects are copied from b to a, but that's 
about it.)

In thinking about "assign" and "assignment", I think of something new being 
created (the assignment) to be given to the assignee. You can assign a role 
or a fortune or a quote to someone, but you can't assign it to multiple 
people without breaking it up into individual assignments. This is like C's 
assignment, but not Python's.

A more appropriate word would probably be "point", as in taking a and 
pointing it to whatever b was pointing at. "point a at what b is pointing 
at".

Also, in all my experience with Python, it has never been absolutely 
necessary to write:

	while a = something(): ...

You don't have to do that. Instead you just make an iterator or a list and 
then use "for". Or you set up an infinite loop and you break out of it when 
you no longer have stuff to do. These just make more sense, and it lends to 
increasing readability. I've always liked that feature of Python: Only do 
one thing on one line.

-- 
Jonathan Gardner
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.