> Isn't it the case that actually p.subs(x2=x2) is *equivalent* to p.subs
> ({'x2':x2}) in Python?

No, this isn't the same in Python. You are looking for:

sage: R.<x0,x1,x2>=QQ[]
sage: S = QQ['x0,x1,x2,x3']
sage: p=S.random_element()
sage: p.subs(x2=x2)

and

sage: p.subs(**{'x2':x2})
-7/2*x1*x2 + 1/2*x2^2 - x0*x3 + 1/165*x1 + 3

Note the two stars. The reason why the subs function accepts a dictionary is 
that its signature is:

    p.subs(self, fixed, **kw=None)

i.e. it also accepts a dictionary 'fixed'. This dictionary expects its keys to 
be variables and not strings of variable names.

Cheers,
Martin

-- 
name: Martin Albrecht
_pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
_otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF
_www: http://www.informatik.uni-bremen.de/~malb
_jab: [email protected]


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to