ADVANCED
PYTHON
Session 1
GENERATORS
Generators provide a way to generate values on the
fly as they’re needed without storing them in memory.
Example:
We use the yield statement in generators. This
statement yields a value to the caller and temporarily
suspends the execution of the generator until the next
value is requested.
It remembers its state and when resumed, the
function continues where it left off.
DESCRIPTORS
With descriptors, you can customize the attribute
access. It enables you to define custom behavior
when getting, setting & deleting attributes by defining
specific methods.
Example:
DECORATORS
A decorator allows us to wrap another function to
extend the behavior of the wrapped function, without
permanently modifying it.
Example:
COMPREHENSIONS
Comprehensions help us with a short and concise way
to create new sequences (such as lists, sets,
dictionaries, etc.).
List Comprehension:
Dictionary Comprehension:
Set Comprehension:
Generator Comprehension:
THANK YOU