Re: Automatic debugging of copy by reference errors?

2006-12-11 Thread Russ
greg wrote: > You need to stop using the term "copy by reference", > because it's meaningless. Just remember that assignment I agree that "copy by reference" is a bad choice of words. I meant pass by reference and assign by reference. But the effect is to make a virtual copy, so although the phr

Re: Automatic debugging of copy by reference errors?

2006-12-11 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Beliavsky wrote: >> ISTM the big catch for Fortran programmers is when a mutable container >> is referenced from multiple places; thus a change via one reference >> will confusingly show up via the other one. > > As a Fortranner, I agree. Is there an explanation online of

Re: Automatic debugging of copy by reference errors?

2006-12-11 Thread Beliavsky
Carl Banks wrote: > Niels L Ellegaard wrote: > > Marc 'BlackJack' Rintsch wrote: > > > In <[EMAIL PROTECTED]>, Niels L > > > Ellegaard wrote: > > > > I have been using scipy for some time now, but in the beginning I made > > > > a few mistakes with copying by reference. > > > But "copying by refer

Re: Automatic debugging of copy by reference errors?

2006-12-11 Thread greg
Russ wrote: > The copy by reference semantics of Python give it great > efficiency but are also its achille's heel for tough-to-find bugs. You need to stop using the term "copy by reference", because it's meaningless. Just remember that assignment in Python is always reference assignment. If you w

Re: Automatic debugging of copy by reference errors?

2006-12-10 Thread Carl Banks
Niels L Ellegaard wrote: > Marc 'BlackJack' Rintsch wrote: > > In <[EMAIL PROTECTED]>, Niels L > > Ellegaard wrote: > > > I have been using scipy for some time now, but in the beginning I made > > > a few mistakes with copying by reference. > > But "copying by reference" is the way Python works.

Re: Automatic debugging of copy by reference errors?

2006-12-10 Thread Carl Banks
Russ wrote: > If a debugger could tell you how many references exist to an object, > that would be helpful. import sys sys.getrefcount(a) But I doubt it would be very helpful. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Automatic debugging of copy by reference errors?

2006-12-09 Thread greg
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

Re: Automatic debugging of copy by reference errors?

2006-12-09 Thread Gabriel Genellina
On 9 dic, 09:08, "Niels L Ellegaard" <[EMAIL PROTECTED]> wrote: > Now some of my fortran-using friends would like to use python to > analyze their data files. I wanted them to avoid making the same > mistakes as I did so I thought it would be good if they could get some > nanny-like warnings say

Re: Automatic debugging of copy by reference errors?

2006-12-09 Thread Gabriel Genellina
> I think what you want is a namespace that requires each object to have > exactly one reference - the namespace. Of course, additional references > will be created during evaluation of expressions. So the best you can do It's not enough. It won't catch the case where a list holds many reference

Re: Automatic debugging of copy by reference errors?

2006-12-09 Thread Stuart D. Gathman
On Sat, 09 Dec 2006 05:58:22 -0800, Niels L Ellegaard wrote: > I wanted a each object to know whether or not it was being referred to > by a living object, and I wanted to warn the user whenever he tried to > change an object that was being refered to by a living object. As far > as I can see th

Re: Automatic debugging of copy by reference errors?

2006-12-09 Thread Fredrik Lundh
Niels L Ellegaard wrote: > I wanted a each object to know whether or not it was being referred to > by a living object, and I wanted to warn the user whenever he tried to > change an object that was being refered to by a living object. As far > as I can see the garbage collector module would al

Re: Automatic debugging of copy by reference errors?

2006-12-09 Thread Niels L Ellegaard
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Niels L > Ellegaard wrote: > > I have been using scipy for some time now, but in the beginning I made > > a few mistakes with copying by reference. > But "copying by reference" is the way Python works. Python never copies > objects unless y

Re: Automatic debugging of copy by reference errors?

2006-12-09 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Niels L Ellegaard wrote: > I have been using scipy for some time now, but in the beginning I made > a few mistakes with copying by reference. But "copying by reference" is the way Python works. Python never copies objects unless you explicitly ask for it. So what you wan

Re: Automatic debugging of copy by reference errors?

2006-12-09 Thread Niels L Ellegaard
Gabriel Genellina wrote: > I think you got in trouble with something and you're trying to avoid it > again - but perhaps this is not the right way. Could you provide some > example? I have been using scipy for some time now, but in the beginning I made a few mistakes with copying by reference. The

Re: Automatic debugging of copy by reference errors?

2006-12-08 Thread Gabriel Genellina
On 9 dic, 02:22, "Niels L Ellegaard" <[EMAIL PROTECTED]> wrote: > Is there a module that allows me to find errors that occur due to copy > by reference? What do you mean by "copy by reference"? > I am looking for something like the following: > > >>> import mydebug > >>> mydebug.checkcopybyrefer

Automatic debugging of copy by reference errors?

2006-12-08 Thread Niels L Ellegaard
Is there a module that allows me to find errors that occur due to copy by reference? I am looking for something like the following: >>> import mydebug >>> mydebug.checkcopybyreference = True >>> a=2 >>> b=[a] >>> a=4 Traceback (most recent call last): File "", line 1, in ? CopyByReferenceError: