The following is an example which defines a class from which you can
manipulate functions :
-------------------------------------------------
#! /usr/bin/sage -python
# -*- coding: utf8 -*-
from sage.all import *
class MaClasse(object):
def __init__(self,exp):
self.sage = exp
self.sageFast = self.sage._fast_float_(x)
def Derr(self):
return MaClasse(self.sage.derivative())
def Evaluation(self,xe):
return numerical_approx(self.sageFast(xe))
var('x,y')
f = MaClasse(x**2+2)
print f.Derr().sage
print f.Derr().Evaluation(3)
print f.Evaluation(8)
--------------------------------------
Copy-paste it in a text file, make it executable, and enjoy !
Laurent
Other point : when I write scripts like the one I posted, the execution
is quite slow, at least, it takes a while before starting. I suppose
that the line
from sage.all import *
takes ages.
Is there a way to import less ?
Have a good afternoon
Laurent
No, unfortunately there isn't.
-- William
> I've tried to import both sage and pygtk without success, both in
> python and sage console. Please tell me if you can achieve this. I
> guess you have to install the module within sage, even if it is
> installed in the system, but outside sage.
>
Sage only knows about python modules installed within its python
installation so any other python modules you want to use with it
have to be installed there.
Cheers,
Tim.
---
Tim Lahey
PhD Candidate, Systems Design Engineering
University of Waterloo
http://www.linkedin.com/in/timlahey
The same here :
#! /usr/bin/sage -python
# -*- coding: utf8 -*-
from sage.all import *
import sys # sys n'est utilisé que pour la partie Qt.
from PyQt4 import QtCore, QtGui
produces :
Traceback (most recent call last):
File "./sagess.py", line 6, in <module>
from PyQt4 import QtCore, QtGui
ImportError: No module named PyQt4
...
well. Good to know.
Laurent
Note you can also do
sage -python
to run Sage's Python. Thus to install packages, you can do stuff like
sage -python setup.py install
- Robert