Automatic debugging of copy by reference errors?

greg greg at cosc.canterbury.ac.nz
Sat Dec 9 21:36:38 EST 2006


Niels L Ellegaard wrote:
> I wanted to warn the user whenever he tried to
> change an object that was being refered to by a living object.

To see how fundamentally misguided this idea is,
consider that, under your proposal, the following
program would produce a warning:

   a = 1

The reason being that the assignment is modifying
the dictionary holding the namespace of the main
module, which is referred to by the main module
itself. So you are "changing an object that is
being referred to by a living object".

--
Greg



More information about the Python-list mailing list