Consider parse function for str to bool
Open
- Dominant language
- Python
- Stars
- 131
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
http://stackoverflow.com/questions/715417/converting-from-a-string-to-boolean-in-python
Probably something like this is best, as it's strict but reasonable:
```
def parse_bool(val):
if val in [True, 1, "True", "true"]:
return True
elif val in [False, 0, "False", "false"]:
return False
else:
raise ValueError("Not parsable as a boolean: %r" % val)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.