Let's try to divert the topic away from the embarrassing mistake i made:) For the graph editor I am still struggling with the update function, because the original graph variable name is lost once graph_editor is called.
python function graph_editor(g) gets the graph representation and sends it to the JS. Once JS is done, its spits out the data. But now question to overwrite the python variable which is locally 'g', but globally something else. that is if the user calls graph_editor(my_graph), how can the JS later call 'my_graph=....' (when the user hits update button). Rado P.S. how do i change the topic of the thread On Aug 3, 4:25 pm, Rado <rki...@gmail.com> wrote: > ops, my bad ... and i thought i knew python :) > > Rado > > On Aug 3, 4:04 pm, Kwankyu <ekwan...@gmail.com> wrote: > > > On Aug 4, 5:21 am, 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). > > > > 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 > > > Graphs are nothing special. Try the following: > > > def modify(G): > > G.delete_vertex(0) > > G=graphs.PetersenGraph() > > modify(G) > > G > > > In your example, you assign a different object to G, thus losing the > > original reference. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---