We looked at several high-level constructs that allow you to describe all sorts of collections and infinite data streams.
It is safe to say that these constructions are a language within a language. High-level constructs may be incomprehensible to novice Python programmers, but their expressive power can tell you about many things briefly.
Generation with yield
is more like regular imperative Python, but using this style forces you to interpret the code in your head. This interpretation is more challenging than reading regular imperative code. This difficulty stems from the fact that with imperative code, you don't have to figure out how to suspend a function or traverse the function body several times.
Procedures
We've left out co-procedures, which are generators to which you can send messages and expect them to give you more than just the next batch of data.
Co-procedures is a large and complex field. Even experienced programmers struggle to learn how to write, understand, and debug co-procedure code. In Python, all asynchrony is built on procedures, although you can work with them without fully understanding all the intricacies.
Object style generators
We did not cover another side of generators: writing generators in object style. To understand this area, you need to learn the basics of OOP. It is material for future courses. Some of the more complex and narrow topics are beyond the course, but the ability to use the tools we've described already gives programmers powerful tools for working with data.
Are there any more questions? Ask them in the Discussion section.
The Hexlet support team or other students will answer you.
For full access to the course you need a professional subscription.
A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.