Hello,
On Wed, Oct 7, 2009 at 12:08 AM, john_perry_usm <[email protected]> wrote:
> sage: f(yvar = xvar)
> x^2 + y^2
> sage: f({yvar:xvar})
> 2*x^2
>
> I was under the impression that both forms of substitution should
> return the same thing, but apparently not. Can someone explain the
> distinction to me?
Doing f(yvar=xvar) is basically equivalent to doing f({'yvar':xvar})
because of the way keyword arguments in Python work. Since, 'yvar' is
being passed in as a string, the best that Sage could hope for is that
there is a variable with the name "yvar". Since there isn't, then no
substitution is done. When you call it the other way, the function
gets the actual object that yvar refers to and is able to make the
correct substitution.
--Mike
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---