projects
/
linpy.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Check symbol names
[linpy.git]
/
linpy
/
linexprs.py
diff --git
a/linpy/linexprs.py
b/linpy/linexprs.py
index
cf2a980
..
834c3b4
100644
(file)
--- a/
linpy/linexprs.py
+++ b/
linpy/linexprs.py
@@
-456,8
+456,13
@@
class Symbol(LinExpr):
"""
if not isinstance(name, str):
raise TypeError('name must be a string')
"""
if not isinstance(name, str):
raise TypeError('name must be a string')
+ node = ast.parse(name)
+ try:
+ name = node.body[0].value.id
+ except (AttributeError, SyntaxError):
+ raise SyntaxError('invalid syntax')
self = object().__new__(cls)
self = object().__new__(cls)
- self._name = name
.strip()
+ self._name = name
self._coefficients = {self: Fraction(1)}
self._constant = Fraction(0)
self._symbols = (self,)
self._coefficients = {self: Fraction(1)}
self._constant = Fraction(0)
self._symbols = (self,)