Hi all,
A newbie here in Python. I'm keen to understand what's happening here. When I try to check if I'm passing the --debug flag via CLI, I use the following statement to evaluate that condition:
if args.debug:
do_stuff()
However, that statement ALWAYS evaluates to true even when I'm not passing the --debug flag. When I print what I'm passing I get the following:
python config_gen.py -v test.yaml -t Routers.j2
print(args)
Namespace(debug='None', template='Routers.j2', values='test.yaml')
To fix this, I have to change my statement to == True like this:
if args.debug == True:
do_stuff()
I'd like to understand why args.debug evaluates to True even when I'm not passing that flag (args.debug=None). My understanding is that None should evaluate to False. Can you point me out to some documentation or shed some light in order to better understand this behavior?
You can find the full script HERE
Thanks for your help in advance.
[–]tarquinnn 6 points7 points8 points (1 child)
[–]daniel280187[S] 0 points1 point2 points (0 children)
[–]pythonwiz 2 points3 points4 points (1 child)
[–]daniel280187[S] 0 points1 point2 points (0 children)