[Fixed] Wrong bool evaluation?

Hi guys
I have these lines of code in form code exactly one below the other:

      a = 'test'
      print a
      print ( a != '' )
      print ( a != None )
      print ( a == None )

How is it this prints out:

test
True
False
False

?

BTW this is an old app’s form code.
I tried to build a new demo-app for this bug with the same code and got a
SyntaxError: bad input
error on the
print a
line.

When I modify it in
print(a)
then I got the correct responses:

test
True
True
False

So I guess the error in the “real” app is due to the fact it’s in python 2.7?

This app is derived from my original python 2.7 app and has the bug:
https://anvil.works/build#clone:BTHUAKCKEPCOIMNW=ZA7LIQVB2H7G73BBAWXT5TRD

This app is built from scratch, is python 3 and has not the bug:
https://anvil.works/build#clone:V6MBT2UWBH4HBOIZ=Q5AMBI4TGHEOSUBYYQU2SEHW

The version of Python in the forms used to be “2.7-ish”, and did have a few idiosyncrasies. The “ish” was because Skulpt (the library that Anvil used to run Python in the browser) had not implemented every 2.7 feature.

They’ve just announced Python 3 client side, and I reckon that is going to fix a lot of quirks.

edit
I’ve just seen that the client side Python 3 is billed as “Python 3.7-ish”, so there may still be a few quirks, but at least it’s Python 3 :slight_smile:

I see.
Strange thing is that the form worked well at least two weeks ago, then it is like something got broken.
Anyway I’ll just fix it up, it’s not a problem for me.

Thanks and have good holydays to you all!

1 Like

Yep, that’s a bug! Moving to Bug Reports…

This is now fixed! Thanks @aldo.ercolani for the report.

1 Like

Thank you guys.
I dont know of it’s related to this latest fix but now I am getting A LOT of these errors:

My app is pratically unusable now.

Ok this is fixed now too.