Lesson 29: File processing and the os module
File processing means reading a file line by line and doing something with each line. The os module adds the filesystem around it: check whether a file exists, list…
Blog
Posts tagged python.
File processing means reading a file line by line and doing something with each line. The os module adds the filesystem around it: check whether a file exists, list…
open() connects a file on disk to a file object in your program. The mode decides whether you read, overwrite or append, and closing the file is what guarantees the…
print() writes to STDOUT — the screen or a terminal — and input() reads a line of text from the keyboard. Everything you already know about strings applies to what…
Three standard modules cover most small needs: math for precise arithmetic, sys for information about the interpreter, and time for clocks and delays. All three…
A module is just a Python file whose functions you can reuse. Write mymath.py with two functions, import it from main.py, and the same code becomes available in…
A lambda is a tiny function written in one line, useful as an argument to another function. Python also ships dozens of built-ins — len, sum, sorted, map, filter…