Google IT Automation with Python key terms
Google IT Automation with Python · Get comfortable with the vocabulary.
- Interpreter
- Related: REPL, Bytecode
A program that reads source code and executes it one statement at a time, without a separate compile step. CPython is the standard implementation used to run .py files and interactive sessions.
- REPL
- Related: Interpreter
Read-Eval-Print Loop: an interactive session that reads one expression, evaluates it, prints the result, and repeats. Useful for quick experiments, checking types, and testing small snippets before scripting.
- Bytecode
- Related: Interpreter, Virtual environment
An intermediate instruction set the interpreter compiles source into and then executes on the Python virtual machine. Cached bytecode lives in pycache folders and explains why first runs are slower.
- List
- Related: Dictionary, Tuple
An ordered, mutable sequence holding items of any type, written with square brackets. Supports indexing, slicing, appending, and sorting, making it the default container for collected results.
- Tuple
- Related: List, Dictionary
An ordered, immutable sequence written with parentheses. Because it cannot change, it can be used as a dictionary key and is a safe way to return multiple values from a function.
- Dictionary
- Related: List, Set
A mutable mapping of unique hashable keys to values, written with braces. Lookups are fast by key rather than position, which suits configuration data and counting occurrences.
- Set
- Related: Dictionary, List comprehension
An unordered collection of unique hashable elements. Membership tests are fast, and set operations such as union, intersection, and difference make it useful for comparing groups of items.
- List comprehension
- Related: Generator, List
A compact expression that builds a list from an iterable in one line, optionally filtering with a condition. It replaces simple for-loop-and-append patterns and is often faster and more readable.
- Generator
- Related: Iterator, List comprehension
A function containing yield that produces values lazily, one at a time, instead of building a full list in memory. Useful for streaming large files or log lines without exhausting RAM.
- Iterator
- Related: Generator, Iterable
An object returned by iter() that yields items one at a time through next and raises StopIteration when exhausted. For loops consume iterators implicitly, which is why a spent iterator yields nothing more.
- Iterable
- Related: Iterator, Generator
Any object a for loop can walk over, such as a list, string, dictionary, or file handle. It produces a fresh iterator via iter(), so it can be looped over repeatedly unlike a spent iterator.
- Exception handling
- Related: Traceback, Assertion
Using try, except, else, and finally blocks to respond to runtime errors instead of crashing. Catch only the specific exception types you can handle, and log or re-raise the rest.
- Traceback
- Related: Exception handling, Logging
The report Python prints when an unhandled exception escapes, listing each call frame from outermost to innermost plus the exception type and message. Reading the last frame first usually locates the fault.
- Module
- Related: Package, Virtual environment
A single .py file whose top-level names can be imported by other code. Importing runs the file once and caches it in sys.modules, so module-level side effects happen only on first import.
- Package
- Related: Module, pip
A directory of modules, normally marked by an init.py file, that gives code a dotted import namespace such as myapp.utils. Distinguishes installable distributions from single-file modules.
- Virtual environment
- Related: pip, requirements.txt
An isolated directory holding its own Python interpreter links and installed packages, created with python -m venv. Prevents project dependencies from conflicting with system packages and keeps deployments reproducible.
- pip
- Related: Virtual environment, requirements.txt
The standard package installer for Python, fetching distributions from an index such as PyPI. Commands include install, uninstall, freeze, and list, and it should normally run inside an activated virtual environment.
- requirements.txt
- Related: pip, Virtual environment
A plain-text file listing package names and optional version pins that pip install -r can reproduce. Generated with pip freeze, it documents exact dependencies so another machine or CI job builds the same environment.
- Command-line arguments
- Related: Exit code, Standard streams
Values passed to a script after its name, read from sys.argv or parsed with argparse. argparse adds flags, defaults, types, and help text, which is preferred for anything beyond trivial scripts.
- Standard streams
- Related: Piping, Logging
The three default channels stdin, stdout, and stderr that a process reads input from and writes output and errors to. Scripts should print diagnostics to stderr so piped stdout stays clean.
- Exit code
- Related: subprocess, Command-line arguments
An integer a process returns to its parent on termination, where zero conventionally means success and nonzero means failure. Shells, schedulers, and CI systems branch on this value, so scripts must set it deliberately.
- Piping
- Related: Standard streams, subprocess
Connecting one process's stdout to another's stdin with the shell | operator, forming a pipeline. Each stage runs concurrently, and the final stage's exit status is what the shell normally reports.
- subprocess
- Related: Exit code, Piping
A standard library module for launching external programs and capturing their output, arguments, and exit status. Preferred over os.system because it avoids shell injection and gives explicit control over streams.
- os module
- Related: pathlib, Environment variable
Standard library interface to the operating system, covering environment variables, directory listing, path checks, permissions, and process identifiers. Many path tasks now have cleaner equivalents in pathlib.
- pathlib
- Related: os module, Glob
An object-oriented standard library module for filesystem paths, offering methods such as exists, is_file, mkdir, and glob. Handles separators portably and replaces much manual string joining with os.path.
- Glob
- Related: pathlib, os.walk
Pattern matching for filenames using wildcards like * and ?, available through glob.glob or Path.glob. Returns matching paths, often used to batch-process files such as all .log files in a directory tree.
- os.walk
- Related: Glob, os module
A generator that yields a tuple of directory path, subdirectory names, and filenames for every folder beneath a starting point. The standard way to traverse a whole tree without writing recursion.
- File context manager
- Related: Exception handling, Standard streams
The with open(...) as f pattern that guarantees the file is closed even if an exception occurs inside the block. Avoids leaked file descriptors and is the expected style in reviewed code.
- CSV module
- Related: File context manager, JSON module
Standard library reader and writer for comma-separated data that handles quoting, embedded delimiters, and newlines correctly. DictReader and DictWriter map rows to dictionaries keyed by header names.
- JSON module
- Related: CSV module, YAML
Standard library encoder and decoder for JSON text via json.loads, dumps, load, and dump. The usual interchange format for APIs and configuration, mapping directly onto dictionaries and lists.
- Regular expression
- Related: Log parsing, String formatting
A pattern language for matching and extracting text, used in Python through the re module. Functions such as search, findall, and sub support log parsing and validation, with raw strings recommended for patterns.
- Logging
- Related: Traceback, Standard streams
The standard library facility for emitting timestamped, leveled messages through configurable handlers. Preferred over print for scripts because levels, rotation, and destinations can change without editing logic.
- Git repository
- Related: Commit, Staging area
A project directory tracked by Git, containing a .git folder that stores commits, branches, and configuration. The working tree holds current files while history lives in the object database.
- Staging area
- Related: Commit, Git repository
The index that records which working-tree changes will go into the next commit. Files are added with git add, and git status distinguishes staged, unstaged, and untracked changes.
- Commit
- Related: Branch, Merge conflict
An immutable snapshot of the staged tree plus author, timestamp, message, and parent pointers. Each has a unique hash, forming the history graph that branches and merges traverse.
- Branch
- Related: Commit, Pull request
A movable pointer to a commit that lets work proceed independently of main. Creating a branch is cheap, and switching with git switch changes which line of history new commits extend.
- Merge conflict
- Related: Commit, Rebase
A state where two branches changed the same lines and Git cannot choose automatically, marking the file with conflict markers. The author resolves the text, stages the file, and completes the merge.
- Rebase
- Related: Merge conflict, Branch
Replaying commits onto a new base to produce a linear history. It rewrites commit hashes, so never rebase commits already shared on a branch others pull from.
- Pull request
- Related: Branch, Code review
A hosted-platform request to merge one branch into another, carrying discussion, review comments, and automated checks. Reviewers approve or request changes before the merge button is enabled.
- Code review
- Related: Pull request, Unit test
The practice of having others inspect a proposed change for correctness, style, security, and test coverage before merge. Comments are addressed with new commits on the same branch.
- Unit test
- Related: Assertion, Test fixture
An automated check that exercises one small unit of code in isolation and asserts the expected result. Fast, deterministic, and independent of network or disk, they run on every change in CI.
- Assertion
- Related: Unit test, Exception handling
A statement that a condition must hold, expressed with assert or a test framework's assertEqual and similar methods. In tests it defines expected behavior; in production code it may be disabled under optimization.
- Test fixture
- Related: Unit test, Mock
Setup and teardown code that prepares a known state before a test and cleans up afterward, such as a temporary directory or database row. Keeps tests repeatable and free of order dependence.
- Mock
- Related: Unit test, Test fixture
A stand-in object that records calls and returns canned values so a test can avoid real network, filesystem, or time dependencies. Provided by unittest.mock and used to assert how collaborators were called.
- Continuous integration
- Related: Unit test, Pull request
A service that automatically runs tests and checks on every pushed change or pull request. Failing pipelines block merges, catching regressions before they reach the main branch.
- Cron job
- Related: Exit code, Logging
A scheduled task defined in a crontab with five time fields plus the command to run. Common for backups and report generation, but output and environment variables differ from an interactive shell.
- Idempotent script
- Related: Cron job, Exception handling
A script that produces the same end state whether run once or many times, for example by checking before creating a user or directory. Essential for safe retries and scheduled automation.
- Log parsing
- Related: Regular expression, Generator
Reading log files and extracting structured fields with string methods or regular expressions to count errors, find slow requests, or feed reports. Often combined with generators to handle files larger than memory.
- Process identifier
- Related: Signal, os module
The unique integer the operating system assigns to a running process, available as os.getpid(). Used to target signals, write lock files, and correlate log lines with a specific run.
- Signal
- Related: Process identifier, Exception handling
An asynchronous notification sent to a process, such as SIGTERM asking it to stop or SIGINT from Ctrl-C. Scripts can trap signals to clean up temporary files before exiting.
- Environment variable
- Related: os module, Cron job
A named string in a process's environment, read via os.environ or os.getenv, commonly used to pass secrets and configuration. Children inherit them, so avoid hardcoding values in scripts.
- String formatting
- Related: Regular expression, Logging
Building text from values with f-strings, str.format, or percent formatting. F-strings are preferred in modern code for readability and inline expressions, including format specs for alignment and decimals.