Hello

   I would like to define a constant function in a script.



I have the following in the terminal :


=====================================================

19:43:28 ~ >$ sage
----------------------------------------------------------------------
| Sage Version 4.0, Release Date: 2009-05-29                         |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: var('x')
x
sage: f(x)= 8
sage: print f.derivative()
x |--> 0
sage: type(f)
<type 'sage.symbolic.expression.Expression'>

=====================================================

That seems quite good.



But the following produce the error
SyntaxError: can't assign to function call
=====================================

#! /usr/bin/sage -python
# -*- coding: utf8 -*-

from sage.all import *

var('x')
f(x)= 8
print f.derivative()

===============================

If I write f=8 instead of f(x)=8, I gat the following :
  File "./sagess.py", line 8, in <module>
     print f.derivative()
AttributeError: 'int' object has no attribute 'derivative'


The difference between the same lines in the terminal and in a very 
simple script seems strange to me.


I'm using the workaround :
var('x')
f = 8+x-x

But ... hum ... seriously ?
;)


Any better idea ?

Thanks a lot
Laurent


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to