On Feb 9, 2008 7:58 PM, mb <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I have a basic question about using pyrex from a sage script. Suppose
> I have a file "test.pyx":
>
> def f(int n):
> return n
>
> Then from the sage interpreter I can use it:
>
> sage: load "test.pyx"
> Compiling test.pyx...
> sage: f(3)
> 3
>
> But I'd like to use it from a script, e.g. "main.sage":
>
> load "test.pyx"
> print f(3)
>
> Then I get:
>
> [EMAIL PROTECTED]:~$ sage main.sage
> Traceback (most recent call last):
> File "main.py", line 4, in <module>
> print f(Integer(3))
> NameError: name 'f' is not defined
>
> I tried modifying test.pyx by inserting the word "public" after "def"
> but it didn't help. Is there any way of doing this?
This is not implemented yet, though it will be implemented.
There is a partial workaround that might be enough for you now.
(1) Create test.pyx and main.sage as follows:
teragon:tmp was$ more test.pyx
def f(int n):
return n
teragon:tmp was$ more main.sage
print f(3)
(2) You can use main.sage if you do the following:
sage: load test.pyx
Compiling test.pyx...
sage: load main.sage
3
This is now trac ticket #2137:
http://trac.sagemath.org/sage_trac/ticket/2137
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-forum
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---