Home | Trees | Indices | Help |
|
---|
|
object --+ | Expression
This class represents an expression.
>>> class A(object): ... x = False ... y = True >>> a = A() >>> e = Expression('x || y') >>> e.eval(a) 1 >>> Expression('99 & 15').eval(a) 3 >>> bool(Expression('(99&15)&&y').eval(a)) True >>> a.hello_world = False >>> def nameFilter(s): ... return 'hello_' + s.lower() >>> bool(Expression('(99 &15) &&WoRlD', name_filter = nameFilter).eval(a)) False >>> Expression('c && d').eval(a) Traceback (most recent call last): ... AttributeError: 'A' object has no attribute 'c' >>> bool(Expression('1 == 1').eval()) True >>> bool(Expression('(1 == 1)').eval()) True >>> bool(Expression('1 != 1').eval()) False >>> bool(Expression('!(1 == 1)').eval()) False >>> bool(Expression('!((1 <= 2) && (2 <= 3))').eval()) False >>> bool(Expression('(1 <= 2) && (2 <= 3) && (3 <= 4)').eval()) True
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
|
|||
|
|
|||
|
|
|||
operators =
|
|
|||
Inherited from |
|
|
|
Partitions expr_str. See examples below. >>> Expression._partition('abc || efg') ('abc', '||', 'efg') >>> Expression._partition('abc||efg') ('abc', '||', 'efg') >>> Expression._partition('abcdefg') ('abcdefg', '', '') >>> Expression._partition(' abcdefg ') ('abcdefg', '', '') >>> Expression._partition(' (a | b) & c ') ('a | b', '&', 'c') >>> Expression._partition('(a | b)!=(b&c)') ('a | b', '!=', 'b&c') >>> Expression._partition('(a== b) &&(( b!=c)||d )') ('a== b', '&&', '( b!=c)||d') >>> Expression._partition('!(1 <= 2)') ('', '!', '(1 <= 2)') >>> Expression._partition('') ('', '', '') >>> Expression._partition('(1 == 1)') ('1 == 1', '', '') |
|
operators
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Oct 10 19:03:57 2011 | http://epydoc.sourceforge.net |