or the load command could exactly replace import, so that

load foo

would load foo.sage in the namespace foo after preparsing, while the
current behavior of load would be achieved by

from foo load *

And "load foo as bar" would work as well. (I don't know if foo should
be replaced by foo.sage thoughout, can't decide)

The problem is that people are used to the current syntax of load...
perhaps what you are suggesting is better. Personally i would find
either way very easy to remember. What would students prefer ? i don't
use sage to teach (yet!), but i suppose it's important. I'm guessing
that creating a new namespace (by default) would prevent them from
making silly mistakes.

On 17 oct, 11:54, "William Stein" <[EMAIL PROTECTED]> wrote:
> On 10/17/07, Pierre <[EMAIL PROTECTED]> wrote:
>
>
>
> > a 'sage-import' command would also make a lot of sense.
>
> Something like that definitely makes sense.
>
> What about
>
>    load foo.sage
>
> to load as usual, and
>
>    sage_import foo.sage
>
> to do the same as load but put everything in the foo namespace?
> I wonder if the command will be too hard to remember.
> Another possibility would be:
>
>    load foo.sage as foo
>
> would make it so everything in foo.sage is imported into the foo
> namespace.  Then
>
>    attach foo.sage as foo
>
> could also be implemented.  Also one could do
>
>     load foo.sage as bar
>
> to put everything in the bar namespace.
>
> Thoughts?
>
>
>
> > On 17 oct, 11:28, Pierre <[EMAIL PROTECTED]> wrote:
> > > perhaps i'm being silly: i'm assuming that it is possible to preparse
> > > right after 'import' has located the file, and still before it
> > > actually does import it ! this would require modifying python, a bit
> > > of a pain!
>
> > > On 17 oct, 11:23, Pierre <[EMAIL PROTECTED]> wrote:
>
> > > > my suggestion is that the standard extension should not be .sage, but
> > > > rather .sage.py so import foo.sage would import foo.sage.py. It will
> > > > also help python IDEs (thanks for the emacs tweak btw). And i believe
> > > > it is true to sage's nature.
>
> > > > Then, import should preparse if the extension is .sage.py, not if it
> > > > is just .py.
>
> > > > what do you think ?
>
> > > > On 17 oct, 11:14, "William Stein" <[EMAIL PROTECTED]> wrote:
>
> > > > > On 10/17/07, Pierre <[EMAIL PROTECTED]> wrote:
>
> > > > > > I was wondering how to have my scripts preparsed: now i know. And i
> > > > > > need to tell emacs that a .sage file needs to be treated like a .py
> > > > > > file...
>
> > > > > Put this in your .emacs file:
>
> > > > > (setq auto-mode-alist (cons '("\\.sage\\'" . python-mode) 
> > > > > auto-mode-alist))
>
> > > > > > a problem with .sage files though is that the import command doesn't
> > > > > > work with them (foo.sage is not found by either 'import foo' or
> > > > > > 'import foo.sage'). I *know* there is the 'load' or the 'attach'
> > > > > > command instead, but really i prefer import, because of what it does
> > > > > > with namespaces: having 'foo.f()' is less likely to clash with 
> > > > > > f()...
> > > > > > same with variables.
>
> > > > > I understand.   It would indeed be god to have some sort of "preparse
> > > > > then import" command.  Any suggestions for how it would work (i.e.,
> > > > > from the user's point of view)?  Making
> > > > >      import foo
> > > > > work if foo.sage is there isn't really an option, since Python 
> > > > > directly
> > > > > does the import, and won't know to look for foo.sage.
>
> > > > > William
>
> --
> William Stein
> Associate Professor of Mathematics
> University of Washingtonhttp://wstein.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-forum
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to