Did I find the right examples for you? yes no

All Samples(4)  |  Call(4)  |  Derive(0)  |  Import(0)
Returns True if 'other' is contained in 'self' as an element.

As a shortcut it is possible to use the 'in' operator:

>>> from sympy import Interval

>>> Interval(0, 1).contains(0.5)
True
>>> 0.5 in Interval(0, 1)
True

src/s/y/sympy-HEAD/sympy/core/tests/test_sets.py   sympy(Download)
def test_interval_symbolic():
    x = Symbol('x')
    e = Interval(0, 1)
    assert e.contains(x) == And(0 <= x, x <= 1)
    raises(TypeError, lambda: x in e)
    e = Interval(0, 1, True, True)
    assert e.contains(x) == And(0 < x, x < 1)

src/s/y/sympy-polys-HEAD/sympy/core/tests/test_sets.py   sympy-polys(Download)
def test_interval_symbolic():
    x = Symbol('x')
    e = Interval(0, 1)
    assert e.contains(x) == And(0<=x, x<=1)
    raises(TypeError, "x in e")
    e = Interval(0, 1, True, True)
    assert e.contains(x) == And(0<x, x<1)