Open BenShen98 opened 5 years ago
One possible solution to this could be to wrap all expressions, or just the expressions outputting a Bool
in python, with int(...)
. I believe that would still work in if statements too:
if int(5 < 3):
...
And would convert True
to 1 and False
to 0 in expressions.
Actually, I think that the problem is that you are using python 3 with python 2 syntax. If you try:
print((2>3)-1)
It should convert the Bool
to int
automatically and print the correct answer.
Your print statement works fine for me on python 2. In python 3 it is seeing the print(2>3)
call and is trying to add the result None
to 1.
Actually, I think that the problem is that you are using python 3 with python 2 syntax. If you try:
print((2>3)-1)
It should convert the
Bool
toint
automatically and print the correct answer.Your print statement works fine for me on python 2. In python 3 it is seeing the
print(2>3)
call and is trying to add the resultNone
to 1.
Yes, that's the problem, thanks
So in C we could write code such as below, which is syntactically valid, but somewhat meaningless.
In spec for C, it does say
As result of this do we need translate such exprssion to python?\ It can't be done by just
print (2>3)-1
, as 2>3 returns nontype