I added my function at the bottom of the file:
[matthieu@localhost monoids]$ less free_monoid_element.py | grep toword
    def toword(self):

and tried to import it:
sage: from sage.monoids.free_monoid_element import toword
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)

/home/matthieu/Documents/sage-5.6/<ipython console> in <module>()

ImportError: cannot import name toword
but it doesn't work...
Thanks for your answer.
Matthieu

Le vendredi 21 juin 2013 12:08:39 UTC+2, John Cremona a écrit :
>
> You need to do "from sage.monoid.free_monoid_element import toword" 
> in order for that name to be in the global namespace.  You can 
> automate this by adding your function to what is imported at startup 
> in the file sage/monoids/all.py   where you can see which functions 
> from that file ar already so imported. 
>
> John 
>
>
> On 21 June 2013 11:02, Matthieu Deneufchâtel 
> <[email protected]<javascript:>> 
> wrote: 
> > I created a sandbox, modified the file free_monoid_element.py then 
> rebuilt 
> > the Sage library (see below) but the function I added is not known: 
> > [matthieu@localhost sage-5.6]$ sage 
> > ---------------------------------------------------------------------- 
> > | Sage Version 5.6, Release Date: 2013-01-21                         | 
> > | Type "notebook()" for the browser-based notebook interface.        | 
> > | Type "help()" for help.                                            | 
> > ---------------------------------------------------------------------- 
> > Loading Sage library. Current Mercurial branch is: test 
> > sage: M=FreeMonoid(3,'x,y,z') 
> > sage: a = M.an_element() 
> > sage: toword(a) 
> > 
> --------------------------------------------------------------------------- 
> > NameError                                 Traceback (most recent call 
> last) 
> > 
> > /home/matthieu/Documents/sage-5.6/<ipython console> in <module>() 
> > 
> > NameError: name 'toword' is not defined 
> > 
> > Which step did I skip so that it does not work ? Note that I recently 
> > modified the SAGE_PATH variable (export 
> > SAGE_PATH="/home/matthieu/CHARep/cha"); I don't know if this is 
> important. 
> > 
> > Matthieu 
> > 
> > 
> > 
> > 
> > [matthieu@localhost sage-5.6]$ sage -b test 
> > 
> > ---------------------------------------------------------- 
> > sage: Building and installing modified Sage library files. 
> > 
> > 
> > Installing c_lib 
> > scons: `install' is up to date. 
> > Updating Cython code.... 
> > Executing 0 commands (using 1 thread) 
> > Time to execute 0 commands: 0.0716159343719 seconds 
> > Finished compiling Cython code (time = 0.619333982468 seconds) 
> > running install 
> > running build 
> > running build_py 
> > copying sage/monoids/free_monoid_element.py -> 
> > build/lib.linux-x86_64-2.7/sage/monoids 
> > warning: build_py: byte-compiling is disabled, skipping. 
> > 
> > running build_ext 
> > Executing 0 commands (using 1 thread) 
> > Time to execute 0 commands: 0.00354194641113 seconds 
> > Total time spent compiling C/C++ extensions:  0.0473070144653 seconds. 
> > running install_lib 
> > copying build/lib.linux-x86_64-2.7/sage/monoids/free_monoid_element.py 
> -> 
> > 
> /home/matthieu/Documents/sage-5.6/local/lib/python2.7/site-packages/sage/monoids
>  
>
> > warning: install_lib: byte-compiling is disabled, skipping. 
> > 
> > running install_egg_info 
> > Removing 
> > 
> /home/matthieu/Documents/sage-5.6/local/lib/python2.7/site-packages/sage-0.0.0-py2.7.egg-info
>  
>
> > Writing 
> > 
> /home/matthieu/Documents/sage-5.6/local/lib/python2.7/site-packages/sage-0.0.0-py2.7.egg-info
>  
>
> > 
> > real    0m2.484s 
> > user    0m2.090s 
> > sys     0m0.235s 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "sage-devel" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to [email protected] <javascript:>. 
> > To post to this group, send email to 
> > [email protected]<javascript:>. 
>
> > Visit this group at http://groups.google.com/group/sage-devel. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to