Anton

Alex Martelli aleaxit at yahoo.com
Fri May 23 04:51:38 EDT 2003


<posted & mailed>

Quiet wrote:

> Hello, All.
> I have idea.
> She concerns giving. (=)
> In one cases the link to object is created.
> 
> a = [1, 2, 3]
> b = a
> 
> b is alias a.

Yes (for some creative interpretation of the words).


> In other cases the new object is created.

No, never.


> a = 34
> b = a
> 
> b is new object.

This is simply, totally, and utterly false.

Try printing id(a) and id(b) right after 'b = a' and you will
easily see that what you have written is utterly false.  Right
after the assignment, b and a indicate the SAME object -- no
"new object is created" upon that assignment, but rather the
id values are absolutely and utterly identical in all cases.


As your suggestion for changes to Python seems to be based on a 
total and serious misunderstanding of how Python works today, I
hope you will understand why I do not explain in detail why it
is such a terrible idea in all respects.  Basically, the Python
concept is that when you want a copy you ask for a copy, and you
need no strange weird syntax for the purpose but rather you use
the standard library module copy; if you do not ask for a copy it
means you don't want a copy and so get a reference to the same
original object as the other name refers to.


I would suggest that before you suggest changes you at least make
sure you KNOW the current workings of what you'd like to change.
For example, see:
http://effbot.org/guides/python-objects.htm


Alex





More information about the Python-list mailing list