I'm skeptical about the last one return None
def is_file_for(is_nagyker, type):
if type == KIS_ES_NAGYKER:
return True
elif type == KISKER and not is_nagyker:
return True
elif type == NAGYKER and is_nagyker:
return True
At the first glance, I thought it always return True. Would have been more clear an explicit return False at the end! def is_file_for(is_nagyker, type):
return type == KIS_ES_NAGYKER or \
(type == KISKER and not is_nagyker) or \
(type == NAGYKER and is_nagyker) def is_file_for(is_nagyker, type):
return ((type == KIS_ES_NAGYKER) or
(type == KISKER and not is_nagyker) or
(type == NAGYKER and is_nagyker))
This way, it doesn't break if there is extra whitespace at the end of the line. def is_file_for(is_nagyker, type):
return ((type == KIS_ES_NAGYKER)
or (type == KISKER and not is_nagyker)
or (type == NAGYKER and is_nagyker)) return (
(type == KIS_ES_NAGYKER ) or
(type == KISKER and not is_nagyker) or
(type == NAGYKER and is_nagyker)) def is_file_for(is_nagyker, type):
return ( (type == KIS_ES_NAGYKER)
or (type == KISKER and not is_nagyker)
or (type == NAGYKER and is_nagyker)) def is_file_for(is_nagyker, type):
return (
(type == KIS_ES_NAGYKER)
or (type == KISKER and not is_nagyker)
or (type == NAGYKER and is_nagyker)
)The other reply to you seems to be the best of both worlds.
From what I can tell this is kind of a point of contention among many developers; there are lots of debates when Googling that particular line.
def is_file_for(is_nagyker, type):
return any([
type == KIS_ES_NAGYKER,
type == KISKER and not is_nagyker,
type == NAGYKER and is_nagyker])
I know unsolicited code improvements from strangers isn't the coolest thing in the world, but `any` (and `all`) can really improve clarity for stuff like this. I know I use them quite a bit. any(k in obj for k in other)