Actually, it should not load the graph when graph_generator is loaded. Anyway, I think that if it was the case, the error would be printed a Sage's startup and not when I call the function, which is my current situation :-/
When I remove all the docstrings, this functions is pretty simple : def WorldMap(self): return sage.structure.sage_object.load("graph_world.sobj") I rebuild I start my branch without the slightest problem, but when I type g=graphs.WorldMap() I get : sage: g=graphs.WorldMap() --------------------------------------------------------------------------- NameError Traceback (most recent call last) /user/ncohen/home/.sage/temp/rebelote.inria.fr/4759/ _user_ncohen_home__sage_init_sage_0.py in <module>() /usr/local/sage/local/lib/python2.6/site-packages/sage/graphs/ graph_generators.pyc in WorldMap(self) 2983 """ 2984 -> 2985 return sage.structure.sage_object.load ("graph_world.sobj") 2986 2987 ################################################################################ NameError: global name 'sage' is not defined And I can not understand why, nor how I should do to bypass it :-/ Nathann On Aug 21, 5:28 pm, William Stein <wst...@gmail.com> wrote: > On Fri, Aug 21, 2009 at 4:49 AM, Nathann Cohen <nathann.co...@gmail.com>wrote: > > > > > Do you have any idea how it is possible to call the "load" function > > from graph_generators.py ? > > I cannot use "load" as the function is not defined yet, nor can I > > directly write : > > return sage.structure.sage_object.load("graph_world.sobj") > > > as sage is not defined at that time either... > > You should *not* load the graph into memory when graph_generators.py is > being imported. I'm glad Sage doesn't let you do that, since it would be an > inefficient waste of memory and time to lod that graph every time Sage > starts up. > > Just write code that is called only when the user actually types > > graphs.world*** > > which might cache its result if you want. > > -- William --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---