Hello,

first, since I'm new on this list, let me thank you for this nice piece
of software, which has revolutioned my way of preparing exercises for my
university students.

I'm having some trouble in understanding how Sympy treats the conversion
of Python integers to its own type.

Take the following code:


a = 1
b = 2
c = Symbol( "c" )

constr = a - b * c

pprint( constr )
pprint( constr.subs( {a: Symbol( "d" )} ) )
pprint( constr.subs( {b: Symbol( "d" )} ) )


It already looks strange to me, because while the first "subs" does what
I would like it to do (and hence "pprint" prints "-2⋅c + d"), the second
doesn't (and "pprint" prints "constr" unchanged). Now, I would be fine
with not being able to replace integers with something else, but I'm
puzzled with the incoherence.

But what I can't really understand is why everything works as I intended
if I just set "b" to 1 instead than 2. And the last "subs" stops working
again if I set "a" to 2 instead than 1.

Is there something I'm missing, or is my first "subs" just exploiting
some secret magic which works only by chance and I should not rely on?

thanks for any clarification

Pietro

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
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/sympy?hl=en.

Reply via email to