Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

A part of your question seems to amount to "can I have both a function and a variable with the same print name" and indeed you can. The only slightly tricky bit is that, of course, you cannot have both bound to the same python identifier at the same time. So one solution is:

sage: A_as_a_var=var('A')
sage: A_as_a_function=function('A')
sage: A_as_a_function(A_as_a_var)
A(A)

The fact that the python identifier A is now bound to one of the two as a side-effect is perhaps confusing. If you use other "var" and "function" then you can avoid this problem.

sage: from sage.symbolic.function_factory import function as lib_function
sage: lib_var=SR.var
sage: A_as_a_var=lib_var('A')
sage: A_as_a_function=lib_function('A')
sage: A_as_a_function(A_as_a_var)
A(A)
sage: A
NameError: name 'A' is not defined

i.e., A is bound to neither, so no confusion about what it is bound to.