Answer the question
In order to leave comments, you need to log in
How can I write this code shorter (suggest your options)?
def check_username_and_description(self, status):
if any(x in status.user.screen_name.lower() for x in BOT_SETTINGS['banned_username_userinfo_words']):
return False
if any(x in status.user.description.lower() for x in BOT_SETTINGS['banned_username_userinfo_words']):
return False
return True
Answer the question
In order to leave comments, you need to log in
def check_username_and_description(self, status):
return not any(
x in " ".join([status.user.screen_name, status.user.description]).lower()
for x in BOT_SETTINGS['banned_username_userinfo_words']
)
def check_username_and_description(self, status):
return not bool(
set((status.user.screen_name + " " + status.user.description).lower()).intersection(
set(BOT_SETTINGS['banned_username_userinfo_words'])
)
)
def check_username_and_description(self, status):
return False if any(x in status.user.screen_name.lower() for x in BOT_SETTINGS['banned_username_userinfo_words']) or any(x in status.user.description.lower() for x in BOT_SETTINGS['banned_username_userinfo_words']) else True
def check_username_and_description(self, status):
return not any([word.lower() in BOT_SETTINGS['banned_username_userinfo_words']
for word in (status.user.description, status.user.screen_name)])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question