On Aug 19, 12:48 pm, Bill Hart <goodwillh...@googlemail.com> wrote:
> I'm not sure if that is what he means. He is using Sage to load
> the .py file, not python.
>

Exactly.  Sage interprets .py files as pure Python, I believe.  But it
turns .sage files into .py files which have already been 'preparsed'.
A .py file is just Python, even in Sage.

> So he wants to know which modules to import to be able to use
> multivariate polynomials in Sage from a (sage, not python) .py file.
> He is trying to develop for Sage, not just use it from the sage
> prompt.
>

For making a new file for the Sage library, to use a given object, I
would do

sage: Object?

and see where it lives; one should be able to then do (in the .py
file)

from sage.rings.whatever import some_object

and it ought to work.

However, since he talked about 'loading' it sounded more like the
former issue.  And using the preparse() command to find out how Sage
"really" constructs the ring will still be helpful for creating a Sage
library Python file.


sage: preparse('R.<z1,z2>=PolynomialRing(GF(5),2,"z")')
'R = PolynomialRing(GF(Integer(5)),Integer(2),"z", names=(\'z1\',
\'z2\',)); (z1, z2,) = R._first_ngens(2)'
sage: PolynomialRing?
String Form:    <function PolynomialRing at 0x104cd9b90>
Namespace:      Interactive
File:           /Users/karl-dietercrisman/Downloads/sage-4.5.3.alpha1/
local/lib/python2.6/site-packages/sage/rings/polynomial/
polynomial_ring_constructor.py
Definition:     PolynomialRing(base_ring, arg1=None, arg2=None,
sparse=False, order='degrevlex', names=None, name=None,
implementation=None)
Docstring:
       Return the globally unique univariate or multivariate
polynomial
       ring with given properties and variable name or names.

       There are four ways to call the polynomial ring constructor:

<snip>

so perhaps (I'm not totally familiar with this part of the code)

from sage.rings.polynomial.polynomial_ring_constructor import
PolynomialRing

could work.

Good luck!

- kcrisman

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

Reply via email to