On Sun, May 18, 2008 at 11:53 AM, Michael Schmitz
<[EMAIL PROTECTED]> wrote:
> I had a quick python question for you. I have fixed a number of bugs
> in PyInline, and so now it works quite nicely. However, it's build
> function returns an object with the functions defined. In other
> words, if you type:
>
> m = PyInline.build(code="""int f() { return 5; }""", language="C")
>
> you would need to type m.f() to run the function. How would you
> suggest declaring the function f on the interpreter so you could just
> run f()? Is there a way to iterate over the functions of m and
> redefine them globally?
If your code is itself defined in the notebook you use globals(), e.g.,
sage: g = globals()
sage: g['f'] = 10
sage: f
10
If you want to write external code that goes in the sage library
to modify the interpreter globals you have to just as above, but
the code must be in a Cython file.
-- 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-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---