Most of the time you can do introspection directly in the console or
the notebook. By typing "myobject??<Enter>". But here it fails because
it is compiled code:
sage: eq = sqrt(6) + sqrt(2) == 2 * sqrt(sqrt(3) + 2)
sage: eq
sqrt(6) + sqrt(2) == 2*sqrt(sqrt(3) + 2)
sage: eq.__nonzero__??
Error getting source: <module '__builtin__' (built-in)> is a built-in class
Type: method-wrapper
String form: <method-wrapper '__nonzero__' of
sage.symbolic.expression.Expression object at 0x7feb2c2d5f38>
Docstring: x.__nonzero__() <==> x != 0
Init docstring: x.__init__(...) initializes x; see help(type(x)) for signature
Call docstring: x.__call__(...) <==> x(...)
Note that obj.__nonzero__() is the name of the method called when you
do "bool(obj)". Either you can do
sage: eq??
Type: Expression
String form: sqrt(6) + sqrt(2) == 2*sqrt(sqrt(3) + 2)
Length: 2
File:
/opt/sage_flatsurf/local/lib/python2.7/site-packages/sage/symbolic/expression.so
Definition: eq(self, *args, **kwds)
Source:
...
def __nonzero__(self):
...
and you can look at the source code there. In that case it is probably
the function "test_relation_maxima" which is called.
sage: from sage.symbolic.relation import test_relation_maxima
sage: test_relation_maxima(eq)
True
and you can have a look at its source code following the same procedure.
Vincent
2015-02-26 22:42 UTC+01:00, Christophe Bal <[email protected]>:
> Hello.
>
> How Sage do to evaluate *bool(sqrt(2) + sqrt(6) == 2*sqrt(sqrt(3)+2))* ?
>
> *Christophe BAL*
> *Enseignant de mathématiques en Lycée **et développeur Python amateur*
> *---*
> *French math teacher in a "Lycée" **and **Python **amateur developer*
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.