Created
August 27, 2016 18:06
-
-
Save knowsuchagency/4198bd96f433b42a2725432324cf8135 to your computer and use it in GitHub Desktop.
in-class assignment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Hello foo. | |
This line won't output. | |
Foo Bar. | |
foooooooooo | |
""" | |
# The above text is in the ./file.txt file | |
def lines_with_foo(filepath): | |
with open(filepath) as infile: | |
for line in infile: | |
if 'foo' in line.lower(): | |
yield line | |
if __name__ == "__main__": | |
foo_lines = lines_with_foo("./file.txt") | |
[print(line) for line in foo_lines] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello foo. | |
This line won't output. | |
Foo Bar. | |
foooooooooo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment