Hi everybody, I have a question about the behavior of "del()" Python built-in. In the following example, when I use del() on the copy of a line, it does not delete it, whereas with the original line, it works. Why? I do not understand, because the id is the same for the copy and the original:
####################### from pylab import * import Tkinter as Tk from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg ion() root = Tk.Tk() f = Figure( figsize = (8,7) ) veryplot = FigureCanvasTkAgg( f , master = root ) veryplot.get_tk_widget().pack( side = Tk.LEFT , expand = Tk.YES , fill = Tk.BOTH ) b = f.add_subplot( 211 ) t = arange(0.01, 5.0, 0.01) s1 = sin(2*pi*t) b.plot( t, s1 ) b.plot( t, s1+1 ) print b.lines raw_input('press a key to delete a line with a copy') line_copy = b.lines[-1] print "original id=", id( b.lines[-1] ), "copy id", id( line_copy ) del( line_copy ) # or b.lines.pop() b.figure.canvas.draw() print b.lines raw_input('press a key to delete a line directly') print "original id=", id( b.lines[-1] ) del( b.lines[-1] ) # or b.lines.pop() b.figure.canvas.draw() print b.lines raw_input('press a key to quit') ####################### Thanks in advance, Julien -- python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.9&1+,\'Z (55l4('])" "When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong." (first law of AC Clarke) ------------------------------------------------------------------------------ SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users