If your expression is a pure Python integer or float, you have to
convert it to a SymPy type first to use SymPy methods on it. So

fun2 = Integer(1)

will work. In general, you can use sympify(), or the shorter S() to
convert things to SymPy types.

It works in the SymPy Live online shell because that shell wraps
integers with Integer() automatically.

Aaron Meurer


On Tue, Jun 28, 2016 at 10:35 AM, Adam S <[email protected]> wrote:
> Hi,
> I am getting confused on Python 3 error message using subs:
>
> from sympy import *
> x, y = symbols('x y')
> fun = cos(x) + 1
> fun.subs(x,y)
>
> --> cos(y) + 1
>
> which is okay. It does at it should.
>
> from sympy import *
> x, y = symbols('x y')
> fun2=1
> fun2.subs(x,y)
>
> --> Attribute error: 'int' object has not attribute 'subs'
>
> What is the failure here?  How to fix this?  I used sympy online and it
> works, but on desktop it does not.  Why?
>
> I used recently anaconda to download python 3 and other libraries etc.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/eec9cfdd-1b15-4b3d-8541-a7a2ea157b6a%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6KRJEoqs6nWmxf-ARRL3zeQHwbuEh1Tr3d0TOWAA%3D%2BW0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to