5 Useful Generator Functions In Python

preview_player
Показать описание
In this video I’m going to be showing you five useful generator functions that will help you learn how generators work in more detail.

▶ Become job-ready with Python:

▶ Follow me on Instagram:

00:00 Learning Python made simple
00:05 Intro
00:15 Fibonacci
04:20 Reading lines
07:47 Cumulative sum
12:27 Infinite repeater
14:42 Row reader
17:54 Conclusion
Рекомендации по теме
Комментарии
Автор

if you don't finish the read or csv_row_reader generators, that file is open for the entire duration of the program
the with block should be outside the function

thomaseb
Автор

This is great explanation and best for me to start learning Python, Thank you very much for demo.

bincharinnovik
Автор

3:04 `i` could be replaced with `_` since the value of `i` is never used (line 18):

for _ in range(n):

luketurner
Автор

I've never understood generators in JavaScript, (or any language), but this explained it so well!
I have so many ideas for where to use these in my projects! (I love that learning about one language can teach you about others as well 😊)

liamrwilkins
Автор

hey hey, great material, keep that up!
just wanted to share with you guys other useful thing about generators:
`yield from`
unfortunately I can't past link here to docs
but anyway - it would simplify iterations in examples : )

akcelero
Автор

Really nice explanation! Very understandable. Maybe it would help even more if you showe the result first, then went into "how to code it"

oli
Автор

Can we get a sequel for Bob's story? I am intrigued, it sounds wise

Slangs
Автор

Great video, love from Lahore Pakistan

hamidraza
Автор

This was helpful. But creating generators using classes is way harder I think, you have to set some methods and sometimes the output is the memory address instead of the value you want. Pain

EUJokerBR
Автор

is there a difference for exemple 4. if we do yield from sequence, instead the for item in sequence: yield item

olivierbouchez
Автор

typing.Generator is deprecated alias to collections.abc.Generator.

AlexandrShadchin
Автор

Try to keep more code in the viewport so not just the function but also what called it

samuelec
Автор

8:10 lol numpy calls cumulative sum that too

ahmoin
Автор

So… the line reading one is just map(str.strip, open(…))?

largewallofbeans
Автор

what's the difference between a generator, an iterator, and an iterable?

syrupthesaiyanturtle
Автор

pretty sure iterating over the lines of a file object ensures only one line is read into memory at a time, so not sure the reader generator is actually necessary.

soycrates
Автор

so yield can send out and receive values?? maybe it should be named into something else...

syrupthesaiyanturtle
Автор

thats opposite of what python was developed for

mpty
Автор

How is the fibonacci function useful? Who actually uses it except for someone interviewing a junior dev or someone developing a scrum board app (in which case you only need the first 7 values)

noli-timere-crede-tantum
join shbcf.ru