thanks for your help. On Wed, May 2, 2012 at 8:09 PM, mhs <[email protected]>wrote:
> Hi, > > the same rule applies for modules that are supposed to be included into > SAGE eventually? > So far I always included only the stuff I actually needed in the .py files. > > @yogesh: Starting from SAGE 4.8 there is also a method called > import_statements which displays the module a certain function or object is > defined in. This might help in putting together the list of import > statements. > > Best > MHS > > > On Wednesday, May 2, 2012 2:20:23 AM UTC-4, William wrote: >> >> On Tue, May 1, 2012 at 11:18 PM, P Purkayastha 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 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 > -- 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
