How to use 'how to make python not case sensitive' in Python

Every line of 'how to make python not case sensitive' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
227def prep_case_insensitive(value):
228 """Prepare a string for case-insensitive comparison.
229
230 This is defined in RFC4518. For simplicity, all this function does is
231 lowercase all the characters, strip leading and trailing whitespace,
232 and compress sequences of spaces to a single space.
233 """
234 value = re.sub(r'\s+', ' ', value.strip().lower())
235 return value
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

130def test_case_insensitive_true(self):
131 """Verify that case insensitive variants of 'true' returns the True
132 boolean.
133
134 """
135 values = ['true', 'TRUE', 'True', 'tRuE', 't', 'T', ]
136 for value in values:
137 received = str_to_bool(value)
138 self.assertTrue(received)

Related snippets