projects
/
python-bulletml.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
4c11ea4
)
expr: Improve documentation.
author
Joe Wreschnig
<joe.wreschnig@gmail.com>
Sat, 24 Apr 2010 08:43:22 +0000
(
01:43
-0700)
committer
Joe Wreschnig
<joe.wreschnig@gmail.com>
Sat, 24 Apr 2010 08:43:22 +0000
(
01:43
-0700)
bulletml/expr.py
patch
|
blob
|
history
diff --git
a/bulletml/expr.py
b/bulletml/expr.py
index
a00c99e
..
385b31b
100644
(file)
--- a/
bulletml/expr.py
+++ b/
bulletml/expr.py
@@
-11,6
+11,8
@@
import re
from bulletml.errors import Error
from bulletml.errors import Error
+__all__ = ["ExprError", "NumberDef", "INumberDef"]
+
class ExprError(Error):
"""Raised when an invalid expression is evaluated/compiled."""
pass
class ExprError(Error):
"""Raised when an invalid expression is evaluated/compiled."""
pass
@@
-19,7
+21,6
@@
class NumberDef(object):
"""BulletML numeric expression.
This translates BulletML numeric expressions into Python expressions.
"""BulletML numeric expression.
This translates BulletML numeric expressions into Python expressions.
- The
Examples:
35
Examples:
35
@@
-75,6
+76,7
@@
class INumberDef(NumberDef):
self._value = int(round(self._value))
def __call__(self, params, rank):
self._value = int(round(self._value))
def __call__(self, params, rank):
+ # Avoid int(round(__call__())) overhead for constants.
if self._value is not None:
return self._value
return int(round(super(INumberDef, self).__call__(params, rank)))
if self._value is not None:
return self._value
return int(round(super(INumberDef, self).__call__(params, rank)))