On Wed, Nov 2, 2011 at 12:08 PM, Laurent <moky.m...@gmail.com> wrote:
> In order to anticipate the next question, if you are wotking in a script
> instead of
> the terminal.
>
> The code
>
>        f(x,y)=x*y
>        print f(5,4)
>
> raises
> SyntaxError: can't assign to function call
>
>
> The code
>        x,y=var('x,y')
>        f=x*y
>        print f(4,3)
>
> raises
> DeprecationWarning: Substitution using function-call syntax and unnamed
> arguments is deprecated and will be removed from a future release of Sage;
> you can use named arguments instead, like EXPR(x=..., y=...)
>
> I know two "correct" ways to do that :
>
>        x,y=var('x,y')
>        f=x*y
>        print f(x=4,y=3)
>
> or
>
>        x,y=var('x,y')
>        f=symbolic_expression(x*y).function(x,y)
>        print f(x,y)
>
> Remark that
>
>        f=symbolic_expression(x*cos(y)).function(x,y)
>        print f(0,1)    # 0
>        g=symbolic_expression(x*cos(y)).function(y,x)
>        print g(0,1)    # 1!!
>
> Hope it helps in any way
>
> 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
> URL: http://www.sagemath.org
>


Hi,

I think its a issue of parsing. If your file is called hello.py it
gives the errors you mentioned. However if you call your file
hello.sage it works. If you call your file hello.sage and run

sage hello.sage

it generates a hello.py which I append below -

# This file was *autogenerated* from the file temp.sage.
from sage.all_cmdline import *   # import sage library
_sage_const_5 = Integer(5); _sage_const_4 = Integer(4)
var('x,y')
__tmp__=var("x,y"); f = symbolic_expression(x*y).function(x,y)
print f(_sage_const_5 ,_sage_const_4 )

I think you can now figure out how it is working. Hope it helps.

Rajeev

-- 
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
URL: http://www.sagemath.org

Reply via email to