On Tue, May 1, 2012 at 11:18 PM, P Purkayastha <[email protected]> wrote:
>
>
> On Tuesday, May 1, 2012 11:34:05 PM UTC+8, William wrote:
>>
>> On Mon, Apr 30, 2012 at 10:59 PM, P Purkayastha <[email protected]> wrote:
>> > The problem you are running into is that when you are on the command
>> > line,
>> > all the needed functions are loaded (this is a reason why the Sage
>> > startup
>> > takes time). When you are writing your own library, you need to import
>> > modules that you need.
>> >
>> > You can do that by simply adding
>> >
>> > from sage.all import *
>> >
>> > at the top of your file. If you want to have finer grained import, then
>> > you
>> > will need to look at the function you are calling. You can either look
>> > at
>> > the help by doing (for example)
>>
>> Unfortunately, I recommend that you do *not* do what Purkayastha is
>> suggesting here, unless you really like your code to mysterious
>> crash/segfault, etc.    It is not safe to import anything from the
>> sage library if you have not done "import sage.all".  The import order
>> is critically important, and is done correctly in "sage.all".  If you
>> try to cherry pick bits out of Sage, you are asking for serious
>> trouble.
>>
>>  -- William
>
>
> Interesting. I didn't know that. Thanks for pointing it out.
>
> But is there no way to not import everything? Suppose I am interested in
> only calculus bits. Then do I still need to import everything from sage.all
> instead of only importing from sage.calculus.all?

You should do

  import sage.all

then

  from sage.calculus.all import *

Namespace wise it is good to import little bits.  Just make sure you
do "import sage.all" before that somewhere to make sure that the whole
library gets imported in the proper order.

William

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to