On Tue, May 24, 2011 at 11:42 AM, Robert Kern <robert.k...@gmail.com> wrote:
> On Tue, May 24, 2011 at 10:44, Vinzent Steinberg
> <vinzent.steinb...@googlemail.com> wrote:
>> On 24 Mai, 05:08, Matthew <mrock...@gmail.com> wrote:
>>> You're right - it's unclear if this should be an event or a random
>>> variable. Thanks for the heads up on 'or'. I was hoping to use | for
>>> 'given' in the future. I'll figure this out when I get there. Isn't
>>> '==' ok to use though? Isn't it __eq__? I thought that 'is' was the
>>> forbidden one.
>>
>> '==' is forbidden too, because it is Python equality and not
>> mathematical equality. E.g. in Python:
>>
>>>>> (x + 1)**2 == x**2 + 2*x + 1
>> False
>
> Note that what Vinzent and Ronan mean is not that *Python* forbids
> overriding __eq__ to return other objects. numpy, SQLAlchemy, and
> several other libraries do that just fine. Rather, sympy has decided,
> as a matter of *policy*, to define __eq__ methods in such a way as to
> return a bool, like most other types, in order to allow sympy objects
> to be used in a variety of contexts like most Python objects you will
> encounter. In particular, most sympy objects can be used as dictionary
> keys or set members.

You can use the relationals instead:

In [3]: sympy.Eq(x, 2*y)
Out[3]: x == 2*y


>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
>   -- Umberto Eco
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To post to this group, send email to sympy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sympy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sympy?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to