On Mon, Aug 3, 2009 at 1:21 PM, Rado<rki...@gmail.com> wrote: > > Hello, > > (I apologize if this has been discussed and it is a design decision). > I just noticed that graphs are passed by value instead of passed by > reference (which i think is standard in python).
Graphs are pass by reference. Your function modify below does not modify G, it overwrites it. Instead make a function like def modify(G): G.hello = "world" and test again. William > > example: > > sage:def modify(G): > sage: G=graphs.CompleteGraph(4) > sage:G=graphs.PetersenGraph() > sage:modify(G) > sage:G > Petersen graph: Graph on 10 vertices > > However, a normal python behavior should be. > > sage:def modify_list(L): > sage: L.append(3) > sage:L=[1,2] > sage:modify_list(L) > sage:L > [1,2,3] > > This can be disastrous if your are passing big graphs. > Rado > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~---------~--~----~------------~-------~--~----~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---