madscatt / zazzie

development branch
GNU General Public License v3.0
2 stars 3 forks source link

Need a str/boolean check #85

Open madscatt opened 6 years ago

madscatt commented 6 years ago

Sometimes a variable is defined as a string but the programmer thinks it is a boolean. If one uses statements like

`my_boolean = "False"'

if my_boolean:

will evaluate as True as the my_boolean string exists. We should consider more robust usage of booleans to avoid these types of mistakes.

Note that

my_boolean = ""

if my_boolean:

will evaluate as False.

madscatt commented 6 years ago

In Python 2.7 booleans are subclassed from ints. True and False are not constants!

https://blog.rmotr.com/those-tricky-python-booleans-2100d5df92c

madscatt commented 6 years ago

http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/boolean.html

madscatt commented 6 years ago

Perhaps name all booleans with a suffix _bool e.g.

some_variable_bool

instead of

some_variable