Add another function to simplify your list comprehension
You can make your code more readable by creating a function to simplify your list comprehension. By defining an additional function like so :
def func_on_str(string, func):
return any(funfunc(char) for char in sstring)
you can rewrite the return statement of check_string more clearly:
return [func_on_str(string, func) for func in check_funcs]
(you can see I agree with @SuperBiasedMan that your variable names could be clearer)
Use getattr() and the code gets shorter but not necessarily more readable
If you want to run member functions, here's what you can do ignoring SRP...it is nice and short. I think it's readable, but others may disagree.
check_funcs = ["isalnum",
"isalpha",
"isdigit",
"islower",
"isupper",
]
for func in check_funcs:
print(any(getattr(char, func)() for char in string))
That could be your whole main() function if you wrote one. Or if you want to keep a separate function for printing you can do:
result_list = []
for func in check_funcs:
result_list.append(any(getattr(char, func)() for char in string))
return result_list
or of course you could use a monster list comprehension:
return [any(getattr(char, func)() for char in string) for func in check_funcs]
But I am not sure any of these versions are more readable than what you've got already.