Advanced Python - Generators #01

preview_player
Показать описание
This is a python tutorial for everyone who already knows the basics!
Welcome to Advanced free course, where you can further polish your programming in Python on your own! Begin your adventure with Software-Engineering now!

Advanced Python Course:

Channel Page:

Outro Music:
Outro Music License:

Timecodes
00:00 - Intro
00:06 - What are Generators?
00:30 - Defining a Generator
00:42 - Basic Exceptions
01:30 - Yielding Values (Mode 1)
02:20 - Displaying yielded values
03:08 - Iterating through a Generator
03:40 - Yielding a Fibonacci sequence (Mode 2)
05:44 - Controlled Random List (Mode 3)
07:08 - Outro

#coding #programming #python #tutorial #course
Рекомендации по теме
Комментарии
Автор

If I may, there's a big part missing here: the fact that generator actually don't behave like a list. range() is a generator and the reason why you can do and not run out of memory is because range() is only storing a couple values (start, stop, iter and current value if memory serves me right). Skipping the next() mechanism in your explanation leaves a lot on the side. I would argue that it is the main benefit of the generator pattern. You could illustrate that with the Fibonacci example by creating a Fib class that defines __iter__().
It is just a suggestion, please don't take it as criticism!! You are doing an advanced tutorial, so code a bit more advanced than yielding the result of another generator would be good in my opinion ;-)
Cheers and keep up the great work!

bitscoding
Автор

Nice video! Probably a follow up would be good to show the advantages to use the generators and the yielding. Also, a small note, from my knowledge, it is good/common practice to use "_" instead a var name (like "i") in a for loop, if the (temporary) variable is not used inside the loop.

Vasi_
Автор

I truly needed such course! I coded Python for several years, but unfrequently, which made me know its basics at very good level, but I've barely seen advanced concepts and it's difficult to find them without digging mindlessly into long docs/knowing about the concepts beforehand. Thank you so much for this!

I would add that for this course, showcasing the concept it could be nice to showcase why this concept should be used over different handling - for example, as much as cool generators are, I see no big difference over just appending to the list (the difference I can see is "dot optimisation", I assume?).
And yielding seems to be less control-aimed than lists, because if you yield things from several places, under several conditions, I can easily seen a way for mistakes on what gets into and what doesn't, as it works as if we add those into exactly one list. Please correct me if I understood this wrongly though, I'm really curious on the concept itself.

tom_stephen
Автор

Hey ! I was wondering why you don't use "def my_function(mode:int):" instead of checking the data type with a try/except fonction ?
Great tutorial anyway :)

pitachu_s
visit shbcf.ru