Thanks Johan.As much as anything I wanted to know that I wasn't doing 
something stupid.

On Thursday, 9 June 2016 14:02:16 UTC+2, Johan S. R. Nielsen wrote:
>
> As a package author, you shouldn't force the user to load the functions 
> into 
> the global namespace. However, it might be possible by getting hold of the 
> globals() object or something. 
>
 
Well, actually, if some one explicitly loads the package using something 
like "import mytest" then I think that it is reasonable to load the main 
functions from the package it the global namespace. Thinking about it, sage 
already does something similar (but more explicit) with methods like 
inject_shorthands. Drilling down a little I realised that I can do what I 
want by putting the following into my __init__.py file:

from sage.misc.misc import inject_variable
from mytest.test import atest
inject_variable('atest',atest)

*Question*: do people think that it is reasonable for a package to do this?

Arguments against include that packages "shouldn't force the user to load 
the functions into 
the global namespace" and that this may lead to clashes in the namespace. 
An argument in favour of doing this is that this a more user-friendly and a 
user is unlikely to import a package if they don't want to use it.

Andrew


-- 
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 sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to