See the examples in the other sections for how to use specific interfaces. The interface classes all derive from the generic interface that is described in this section.
AUTHORS:
Bases: sage.structure.parent_base.ParentWithBase
Expect interface object.
INPUT:
EXAMPLES:
sage: maxima.quad_qags(x, x, 0, 1, epsrel=1e-4)
[0.5,5.5511151231257...e-15,21,0]
sage: maxima.function_call('quad_qags', [x, x, 0, 1], {'epsrel':'1e-4'})
[0.5,5.5511151231257...e-15,21,0]
Return the string representation of the variable var in self, possibly using a file. Use this if var has a huge string representation, since it may be way faster.
Warning
In fact unless a special derived class implements this, it will not be any faster. This is the case for this class if you’re reading it through introspection and seeing this.
This allows you to interactively interact with the child interpreter. Press Ctrl-D or type ‘quit’ or ‘exit’ to exit and return to Sage.
Note
This is completely different than the console() member function. The console function opens a new copy of the child interpreter, whereas the interact function gives you interactive access to the interpreter that is being used by Sage. Use sage(xxx) or interpretername(xxx) to pull objects in from sage to the interpreter.
EXAMPLES:
sage: a = maxima('y')
sage: maxima.quit()
sage: a._check_valid()
...
ValueError: The maxima session in which this object was defined is no longer running.
EXAMPLES:
sage: filename = tmp_filename()
sage: f = open(filename, 'w')
sage: f.write('x = 2\n')
sage: f.close()
sage: octave.read(filename) #optional -- requires Octave
sage: octave.get('x') #optional
' 2'
sage: import os
sage: os.unlink(filename)
Bases: sage.structure.element.RingElement
Expect element.
If this wraps the object x in the system, this returns the object x.attrname. This is useful for some systems that have object oriented attribute access notation.
EXAMPLES:
sage: g = gap('SO(1,4,7)')
sage: k = g.InvariantQuadraticForm()
sage: k.attribute('matrix')
[ [ 0*Z(7), Z(7)^0, 0*Z(7), 0*Z(7) ], [ 0*Z(7), 0*Z(7), 0*Z(7), 0*Z(7) ],
[ 0*Z(7), 0*Z(7), Z(7), 0*Z(7) ], [ 0*Z(7), 0*Z(7), 0*Z(7), Z(7)^0 ] ]
sage: e = gp('ellinit([0,-1,1,-10,-20])')
sage: e.attribute('j')
-122023936/161051
Return this element’s string representation using a file. Use this if self has a huge string representation. It’ll be way faster.
EXAMPLES:
sage: a = maxima(str(2^1000))
sage: a.get_using_file()
'10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376'
Returns whether the given attribute is already defined by this object, and in particular is not dynamically generated.
EXAMPLES:
sage: m = maxima('2')
sage: m.hasattr('integral')
True
sage: m.hasattr('gcd')
False
Returns the name of self. If new_name is passed in, then this function returns a new object identical to self whose name is new_name.
Note that this can overwrite existing variables in the system.
EXAMPLES:
sage: x = r([1,2,3]); x
[1] 1 2 3
sage: x.name()
'sage3'
sage: x = r([1,2,3]).name('x'); x
[1] 1 2 3
sage: x.name()
'x'
sage: s5 = gap.SymmetricGroup(5).name('s5')
sage: s5
SymmetricGroup( [ 1 .. 5 ] )
sage: s5.name()
's5'
Attempt to return a Sage version of this object.
EXAMPLES:
sage: gp(1/2).sage()
1/2
sage: _.parent()
Rational Field
Bases: sage.structure.sage_object.SageObject
Expect function.
Bases: sage.structure.sage_object.SageObject
Expect function element.
Bases: object
This is a “with” statement context manager. Garbage collection is disabled within its scope. Nested usage is properly handled.
EXAMPLES:
sage: import gc
sage: from sage.interfaces.expect import gc_disabled
sage: gc.isenabled()
True
sage: with gc_disabled():
... print gc.isenabled()
... with gc_disabled():
... print gc.isenabled()
... print gc.isenabled()
False
False
False
sage: gc.isenabled()
True