๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

Python Intermediate

What is Generator?

A function that yields values one at a time using the yield keyword, enabling memory-efficient iteration over large datasets.

Generators produce values lazily - they compute the next value only when requested. This makes them ideal for processing large files, infinite sequences, or data streams without loading everything into memory.

A generator function uses yield instead of return. Generator expressions use parentheses: (x**2 for x in range(1000000)) creates a generator without allocating memory for all values.

Related Terms

F-String
A formatted string literal prefixed with f that allows embedding Python expressions directly inside curly braces.
Python ABC Module
The Abstract Base Classes module that enables defining interfaces and abstract methods that subclasses must implement.
Virtual Environment
An isolated Python environment that maintains its own set of packages, independent of the system Python installation.
Python Logging Best Practices
Structured approaches to implementing logging in Python applications using the built-in logging module for debugging and monitoring.
Pandas
A powerful data analysis and manipulation library providing DataFrames and tools for working with structured data.
Docstring
A string literal placed as the first statement in a module, class, or function to document its purpose and usage.
View All Python Terms โ†’