EDIT:
The problem only appears when trying to get "direct output" of the result of dict(zip(...
.
This code, with output via print
, works fine
import sympy as sp
x, y = sp.symbols('x,y')
d = dict(zip([x, y], [1, 1]))
print(d)
but simply entering dict(zip([x, y], [1, 1]))
throws the error.
Code as simple as this
import sympy as sp
x, y = sp.symbols('x,y')
dict(zip([x, y], [1, 1]))
Produces error
TypeError: cannot determine truth value of Relational
Why, and how can I solve this?
If not using OrderedDict
, that would be most convenient.
It seems this OP has no problem in doing what is giving me the error (it has a different problem).
Full code, etc. I know it's an old python version, but I guessed it should work.
>>> x, y = sp.symbols('x,y')
>>> dict(zip([x, y], [1, 2]))
Traceback (most recent call last):
File "<string>", line 449, in runcode
File "<interactive input>", line 1, in <module>
File "<string>", line 692, in pphook
File "C:\development\Portable Python 3.6.5 x64 R2\App\Python\lib\pprint.py", line 53, in pprint
printer.pprint(object)
File "C:\development\Portable Python 3.6.5 x64 R2\App\Python\lib\pprint.py", line 139, in pprint
self._format(object, self._stream, 0, 0, {}, 0)
File "C:\development\Portable Python 3.6.5 x64 R2\App\Python\lib\pprint.py", line 161, in _format
rep = self._repr(object, context, level)
File "C:\development\Portable Python 3.6.5 x64 R2\App\Python\lib\pprint.py", line 393, in _repr
self._depth, level)
File "C:\development\Portable Python 3.6.5 x64 R2\App\Python\lib\pprint.py", line 405, in format
return _safe_repr(object, context, maxlevels, level)
File "C:\development\Portable Python 3.6.5 x64 R2\App\Python\lib\pprint.py", line 511, in _safe_repr
items = sorted(object.items(), key=_safe_tuple)
File "C:\development\Portable Python 3.6.5 x64 R2\App\Python\lib\site-packages\sympy\core\relational.py", line 384, in __nonzero__
raise TypeError("cannot determine truth value of Relational")
TypeError: cannot determine truth value of Relational