If, OTOH, your list of strings is indeed hideously long, use a set:
accepted_strings = {'auth', 'authpriv', 'daemon'}
if facility in accepted_strings:
do_stuff()
Testing for containment in a set is O(1) on average.
More Related Contents:
- Good Python modules for fuzzy string comparison? [closed]
- Checking whether a string starts with XXXX
- Unable to use convert strings into integers for a for loop
- Empty string python zapier
- How do I execute a string containing Python code in Python?
- How to format a floating number to fixed width in Python
- Split a string by a delimiter in python
- Split string on whitespace in Python [duplicate]
- How to check if type of a variable is string?
- Iterating each character in a string using Python
- Extracting date from a string in Python
- Pandas DataFrame stored list as string: How to convert back to list
- How to check if a string only contains letters?
- Replace nth occurrence of substring in string
- How to write string literals in python without having to escape them?
- str.startswith with a list of strings to test for
- Remove non-ASCII characters from pandas column
- Split a string only by first space in python
- How to split strings inside a list by whitespace characters
- Difference between using commas, concatenation, and string formatters in Python
- how to do bitwise exclusive or of two strings in python?
- Mutable strings in Python
- How do you check in python whether a string contains only numbers?
- Check presence of vowels in a string
- How do I reverse a string in Python?
- Does R have function startswith or endswith like python? [closed]
- Remove Sub String by using Python
- How to split a Python string on new line characters [duplicate]
- How to Print “Pretty” String Output in Python
- Why do I get “TypeError: not all arguments converted during string formatting” trying to check for an even/odd number?