Thanks; your answer explained it. I don't understand why Python works that way, but I'll bet there's a good reason.
regards john perry On Oct 6, 12:14 pm, Mike Hansen <mhan...@gmail.com> wrote: > Hello, > > On Wed, Oct 7, 2009 at 12:08 AM, john_perry_usm <john.pe...@usm.edu> 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 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 -~----------~----~----~----~------~----~------~--~---