On 1/22/11 8:06 AM, Ivan Andrus wrote:
On Jan 22, 2011, at 1:04 PM, Pedro Cruz wrote:
I was tring to remember if "simple" equality was "=" or "==".
The email is just to mention this:
#1/3 Sage command-line: (4.6)
sage: 1=2
(....)
TypeError: Must construct a function with a tuple (or list) of
symbolic variables.
#2/3 Sage notebook:
1=2
(returns nothing)
But if you try this in a single cell
1=2
1
it returns 2. This is because the preparser turns it into:
_sage_const_2 = Integer(2); _sage_const_1 = Integer(1)
_sage_const_1 =_sage_const_2
_sage_const_1
On the command line:
sage: preparse('1=2')
'__tmp__=var("1"); Integer = symbolic_expression(Integer(2)).function(1)'
It looks like the problem is that it is treating this like f=x^2. Here
is another problem:
sage: var('1')
1
so I think there is definitely a problem with both var() and with the
preparser here.
Since Python doesn't allow identifiers to start with a number [1], we
shouldn't allow var() objects to start with a number.
I suppose someone could use this feature like this:
sage: one=var('1')
sage: one
1
sage: type(one)
<type 'sage.symbolic.expression.Expression'>
but I think that is too confusing to be a good thing.
-Jason
[1] http://docs.python.org/reference/lexical_analysis.html#identifiers
--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org