Based on some experiments, it appears to me that the following Python v2.7 code:
def lookup_pattern(pattern, file_containing_patterns):
for line in file_containing_patterns:
splits = line.split()
if splits:
if (pattern == splits[0]):
return map(lambda x: x.strip(), splits[1:])
return None
Could be simplified as follows to drop the map
of strip()
:
def lookup_pattern(pattern, file_containing_patterns):
for line in file_containing_patterns:
splits = line.split()
if splits:
if (pattern == splits[0]):
return splits[1:]
return None
I believe this is true because the split()
should remove all white space and thus the strip()
would be a no-op.
Are there any cases where in the above two are not identical in effect, if so, what are they?