hmm... the question was different: "attach" makes variable global,
"import" does not. is it bug or feature?


On Oct 28, 5:52 pm, William Stein <wst...@gmail.com> wrote:
> On Wed, Oct 28, 2009 at 5:16 AM, zeliboba <zelibo...@googlemail.com> wrote:
>
> > dear all
>
> > in documentation for var() it is stated "variables ... automatically
> > injected into the global namespace". I'd like to define variable in
> > module and then use it from several scripts, but variable is not
> > exported actually. my prog.sage looks like:
>
> > from mod import *
> > createVar('A')
>
> Do:
>
>    A = var('A')
>
>
>
> > f = A^2
> > print f
>
> > and module mod.py :
>
> > from sage.all import *
> > def createVar(s):
> >    return var(s)
>
> > it gives:
>
> > $ sage prog.sage
> > Traceback (most recent call last):
> >  File "prog.py", line 7, in <module>
> >    f = A**_sage_const_2
> > NameError: name 'A' is not defined
>
> > A is definitely not in global namespace. it only works correctly if I
> > change
> > from mod import *
> > to
> > attach mod.py
>
> > is it intended behavior?
>
> --
> William Stein
> Associate Professor of Mathematics
> University of Washingtonhttp://wstein.org
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to