Re: [sage-devel] Global namespace and independent python packages

2016-06-10 Thread Travis Scrimshaw
Something else you can do on the Sage side is to have something like: try: from sage.foo import Bar except ImportError: pass So it only gets included into the global namespace if you have the module installed. Best, Travis -- You received this message because you are subscribed to the

Re: [sage-devel] Global namespace and independent python packages

2016-06-09 Thread Andrew
On Thursday, 9 June 2016 17:10:44 UTC+2, Johan S. R. Nielsen wrote: > > > 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? > > I would also sa

Re: [sage-devel] Global namespace and independent python packages

2016-06-09 Thread Johan S . R . Nielsen
> 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? I would also say "No". The reason is that if that is what the user wanted, he could just have done "from myt

Re: [sage-devel] Global namespace and independent python packages

2016-06-09 Thread Erik Bray
On Thu, Jun 9, 2016 at 3:42 PM, Andrew wrote: > 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 >>

Re: [sage-devel] Global namespace and independent python packages

2016-06-09 Thread Andrew
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

Re: [sage-devel] Global namespace and independent python packages

2016-06-09 Thread Johan S . R . Nielsen
Hi Andrew, To import into the global namespace use sage: from mytest import * 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. If you want to import the package

[sage-devel] Global namespace and independent python packages

2016-06-09 Thread Andrew
I have been playing around with ta stand-alone python package for sage. It works really well except that I have not found a "nice" way to import classes into the global namespace. I suspect that it is just something in the way that I have configured things, so I've distilled my code down to a m