f.readline() reads a single line from the file; a newline character, (
), is left at the end of the string, and is only omitted on the last line of the file if the file doesn't end in a newline. If you want to read all the lines of a file in a list, you can also use list(f) or f.readlines().
Basically, using with open() just ensures that you don't forget to close() the file, making it safer/preventing memory issues.
r means the string will be treated as raw string.
Generators simplify the creation of iterators. A generator is a function that produces a sequence of results instead of a single value.
The pass statement in Python is used when a statement is required syntactically but you do not want any command or code to execute. The pass statement is a null operation; nothing happens when it executes.
In Python, an anonymous function is a function that is defined without a name. While normal functions are defined using the def keyword, in Python anonymous functions are defined using the lambda keyword. Hence, anonymous functions are also called lambda functions.