You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importfiredefa(flag: bool):
ifflag:
print("hooray!")
else:
print("Wanna see a flag :(")
if__name__=='__main__': fire.Fire(a)
Now, the following options work as expected (print 'hooray!'): python a.py --flag python a.py --flag=True python a.py --flag=true
However, in order to disable flag explicity the only working option is: python a.py --flag=False
and the seemingly rational version python a.py --flag=false
result in 'hooray' being printed as flag is parsed as a string 'false' which then casts to boolean True.
My request:
support 0, 'false' and 'no' as valid boolean arguments that all cast to False. Make this behavior optional. One way to do this is by adding a custom type to lable such flags with.
The text was updated successfully, but these errors were encountered:
Implementing this request would have to come as part of a larger change: using type annotations to infer types and parse arguments accordingly; this isn't planned at this time.
Consider the following code:
Now, the following options work as expected (print 'hooray!'):
python a.py --flag
python a.py --flag=True
python a.py --flag=true
However, in order to disable flag explicity the only working option is:
python a.py --flag=False
and the seemingly rational version
python a.py --flag=false
result in 'hooray' being printed as flag is parsed as a string 'false' which then casts to boolean True.
My request:
support 0, 'false' and 'no' as valid boolean arguments that all cast to False. Make this behavior optional. One way to do this is by adding a custom type to lable such flags with.
The text was updated successfully, but these errors were encountered: