Advertisement
silver2row

__init__.py from matplotlib

Aug 8th, 2020
1,477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. def _string_to_bool(s):
  2.     """Parses the string argument as a boolean"""
  3.     if not isinstance(s, str):
  4.         return bool(s)
  5.     warn_deprecated("2.2", "Passing one of 'on', 'true', 'off', 'false' as a "
  6.                     "boolean is deprecated; use an actual boolean "
  7.                     "(True/False) instead.")
  8.     if s.lower() in ['on', 'true']:
  9.         return True
  10.     if s.lower() in ['off', 'false']:
  11.         return False
  12.     raise ValueError('String "%s" must be one of: '
  13.                      '"on", "off", "true", or "false"' % s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement