On Fri, 21 Aug 2009, Nathann Cohen wrote:

>
> 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 :-/
>

When you start up Sage, a lot of things are imported automaticaly, but you 
need to import them manually to use them from the library itself.

In this case you could do

from sage.structure.sage_object import load
return load("...")

- Robert


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to