Тёмный

Python Tutorial: Iterators and Iterables - What Are They and How Do They Work? 

Corey Schafer
Подписаться 1,3 млн
Просмотров 375 тыс.
50% 1

In this Python Programming Tutorial, we will be learning about iterators and iterables. There is a lot of confusion around these terms and exactly what they mean. We're also going to learn how to make an object ourselves that is both an iterable and an iterator. This video isn't only about understanding these definitions. It's also about understanding the concepts of iterators so that you can write better code. Understanding these underlying concepts is going to help you write code that is more efficient and will also help you see solutions to certain problems in a way you might not have thought of before. So with that said, let's get started...
The code from this video can be found at:
github.com/CoreyMSchafer/code...
Coding Problem for This Video:
• Python Coding Problem:...
Object-Oriented Series:
• Python OOP Tutorials -...
✅ Support My Channel Through Patreon:
/ coreyms
✅ Become a Channel Member:
/ @coreyms
✅ One-Time Contribution Through PayPal:
goo.gl/649HFY
✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
✅ Corey's Public Amazon Wishlist
a.co/inIyro1
✅ Equipment I Use and Books I Recommend:
www.amazon.com/shop/coreyschafer
▶️ You Can Find Me On:
My Website - coreyms.com/
My Second Channel - / coreymschafer
Facebook - / coreymschafer
Twitter - / coreymschafer
Instagram - / coreymschafer
#Python

Опубликовано:

 

26 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 319   
@erdi749
@erdi749 2 года назад
These tutorials are epic, how can you talk 20mins without any single unnecessary word, truly amazing. Thank you so much Corey. You are my #1 Pyhton reference in my classes I teach in the collage! Keep up the great work!
@informativecontent4778
@informativecontent4778 Год назад
practice
@gioxc88
@gioxc88 5 лет назад
best python instructor ever
@alkhashtee
@alkhashtee 5 лет назад
True
@ikhairi83
@ikhairi83 5 лет назад
While True:
@waex7089
@waex7089 5 лет назад
100% True
@jcinaz
@jcinaz 5 лет назад
I couldn’t agree more.
@shreyashimukhopadhyay6354
@shreyashimukhopadhyay6354 4 года назад
HardCore my thoughts exactly!
@WaldoTheWombat
@WaldoTheWombat Год назад
1. In Python, an object can be called an "iterable" if it has the dunder method __iter__ which should return an iterator and an iterator is an object that has the method __next__. 2. __iter__ is a method that a python list has. 3. By performing the for loop on the list, python invokes that list's __iter__ method which returns an iterator that we can loop over. we can do next(mylist.__iter__()) which invokes the iterator's __next__ method or call or invoke it directly: mylist.__iter__().__next__() we can also do next(iter(mylist)) "Generators are iterators as well, but the duder iter and duner next methods are created automatically."
@judeleon8485
@judeleon8485 4 года назад
Corey, you're awesome! You always make my day. Anytime I'm in need need of a lesson on any python topic, your channel is always my first port of call, to see if you have it. You always know how to make it sink in so well. Thanks
@mahesh9762132636
@mahesh9762132636 5 лет назад
Corey Schafer ... U are the only Foreign RU-vid, Instructor of Python whom i Follow. Your Videos contains information multifolds 10 which we get from any other video.. I am Surprised how do u do this...You make Sound Python Like Childs Play ... Hats off to u ... Expecting Machine Learning from You. That could be the Internet Breaker Videos of Yours
@techcode_man
@techcode_man 5 лет назад
Corey, Thank you for explaining this so well and simple. I have been using both iterators and iterables for while, now it makes a lot of sense.
@veeplusvee
@veeplusvee 2 года назад
Corey, Simply you are the best when it comes to making someone understand the concept. Unless someone understands the concept, it is very difficult to write codes that are lot efficient and at the same time very easy to understand/read. I wish everyone who makes video on programing follows a similar template for teaching. Thanks a lot.
@shahzebafroze4093
@shahzebafroze4093 5 лет назад
Thank you for making these awesome videos!! Goal after graduation: support your channel.
@Worldofdave
@Worldofdave 3 года назад
Did you by now :D
@pedrocontrerasavendano8578
@pedrocontrerasavendano8578 5 лет назад
Precise, coherent, well articulated and well structured; good tutorial, thanks
@feernot
@feernot 5 лет назад
You seriously teach this stuff better than anyone I've found. Thank you so much!
@furankuraw7741
@furankuraw7741 5 лет назад
Thank you so much for the consistent videos and tutorials and the help that you provide for people new to this ^^
@ErnestGWilsonII
@ErnestGWilsonII 5 лет назад
Dang it, I wanted to say FIRST! :)
@yaboi1525
@yaboi1525 3 года назад
You're the best instructor I ever had. Thanks for all your precious efforts it mean a lot.
@emmanuel5566
@emmanuel5566 4 года назад
dude.. your voice is so distinct and your explanation is crystal clear. if I can't find something on StackOverflow or if I'm learning a new concept in python, your channel is THE resource for me. Great content. Thank you for keeping it free.
@halim1885
@halim1885 5 лет назад
i've tried a lot of teachers in order to make progress and non of them works , you are the best sir i advise everyone want to learn python to watch your serie
@baqirhusain5652
@baqirhusain5652 4 года назад
Oh My God....I didn't know learning python can be this addictive.... Thank you sooooooooooooooo muchhhh
@aman0509
@aman0509 4 года назад
Closure and Decorator tutorial of yours was my first experience and I am telling you, you have explained it in such a good way that I cannot forget it ever. I am not being dramatic but your explanation method is magical. When I am learning any concept, there are things which are buried inside my mind and but it cannot get out because I feel confused and also nobody talking about the same or have that kind of explaining system as yours. It's like you are connected to my mind. So, Thank You Very Much!! God Bless You!!
@coreyms
@coreyms 4 года назад
Thanks! Glad to hear that
@HareshRathod
@HareshRathod 4 года назад
OMG! Watching since last 4.5 hours, dont know when last I have wateched videos for so long. Addictive. Corey you must be a Teacher. Thanks for such nice videos
@Matharendre
@Matharendre Год назад
It really sums up the concepts in a concise but precise way. Thank you a lot for this!
@Greenbay-bn3yk
@Greenbay-bn3yk Месяц назад
Old but Gold. What an excellent explanation
@beginner_bro
@beginner_bro 17 дней назад
This is your first video I am watching. And this single video forced me to subscribe your channel. Great job man
@chuckles8519
@chuckles8519 Год назад
You have a very clear teaching style - a very valuable talent to have!
@DomenicoTanzarella
@DomenicoTanzarella 4 года назад
Brilliant Corey: one of your best videos!
@MehmetMustafaICER
@MehmetMustafaICER 4 года назад
Thank you for this video. It is pretty clear and to-the-point. Well done.
@venkatdevireddy650
@venkatdevireddy650 5 лет назад
Ur videos are awesome Corey I have been watching all ur videos... please make an video on SYS module as well as XML parsing...I have got bunch of videos from you tube none other videos are up to the mark as u...ur explanation in any concept is at peeks no body beats u... thanks a lot
@albertdugba
@albertdugba 5 лет назад
You're definitely the best python instructor on RU-vid by far...But some of us will appreciate it you could maximise the screen size we can clearly see instead of straining our eye which is probably not the best. Thank you
@zhukovmisha
@zhukovmisha 5 лет назад
Thank you for such a profound explanation!
@IterativeTheoryRocks
@IterativeTheoryRocks 4 года назад
Excellent idea with the coding problems. You never really understand something until you have to use it!
@sg8581
@sg8581 11 месяцев назад
One of the best explanations on iterators. Thanks a ton!
@DioD3
@DioD3 4 года назад
Excellent video. Thank you! You are my favorite programing(python) teacher.
@xaverxassnytz2746
@xaverxassnytz2746 5 лет назад
very good explanation in this and generators video (also watched your other videos) - thanks to Corey coming from old languages like Fortran, Cobol, Pascal and I just began learning python 3 months ago and this videos helped me a lot to get a basic knowledge
@adamobaid3558
@adamobaid3558 5 лет назад
Thank you, you are great instructor. These videos are awesome and have helped me so much. I will make a contribution when I get hired soon!
@ji-axinliu4448
@ji-axinliu4448 2 года назад
Thank you, Sir. I wake up at 4 in the morning and continue watching your lessons.
@DevinderKumar
@DevinderKumar 4 года назад
Super, very useful lesson. Great stuff in a shortest possible time. Thanks a lot.
@zyenapz
@zyenapz 3 года назад
Thanks for the straightforward and non-verbose explanation!
@user-gq5xs9nh7m
@user-gq5xs9nh7m 7 месяцев назад
thank you so much for this video. I've been queering bing chat and bard chat for a couple of hours on the iterable and iterator topics but none of them managed to explain the stuff to me in a so clear way that you did.
@shashishekhar----
@shashishekhar---- Год назад
Thank you so much Corey, much appreciated how helpful this(these) videos are, just thank you 👍
@swapnilp4629
@swapnilp4629 2 года назад
looks I found this bit late since this was published but trust me Your are the Best . I have gone through so many videos but the way you explain and demonstrate is AWESOME!! Keep it up :) All the best...
@samed3554
@samed3554 Год назад
Very plain and well explained. Thank you Corey, subbed.
@gajatanu2962
@gajatanu2962 7 месяцев назад
Even after years, This is easy to understand and relevant, Thank you very much man
@vvkkumar3691
@vvkkumar3691 4 года назад
Hi Corey, most of my doubt got clear through this channel . Thank u so much for this . I am suggesting two more topic please make a video on those. 1. Why Tuple is faster than List ? 2. Why List comprehension is faster than for loop?
@Ammothief41
@Ammothief41 5 лет назад
So python lists are singly linked lists! Awesome! Thanks for this and the tutorials on generators. I purchased a python book but it never delved into the material as deeply as what I wanted. Thanks.
@thomasziereis330
@thomasziereis330 3 года назад
Python lists are not linked lists
@alexandredamiao1365
@alexandredamiao1365 4 года назад
Your lectures are amazing! Thank you so much for this!
@marioestrada2233
@marioestrada2233 2 года назад
Many thanks man! You are truly great at teaching! Please continue with this awesome work
@hubertcombomarketing2693
@hubertcombomarketing2693 4 года назад
Great Python Iterators and Iterables Tutorial. Thank You.
@hetalchavan9446
@hetalchavan9446 4 года назад
Amazing lecture!Very informative!Already subscribed after seeing this one.
@tunkyi7162
@tunkyi7162 5 лет назад
you are making me clear things up. I gave a like and subscribed to your channel.
@MagnusAnand
@MagnusAnand 4 года назад
This video is amazing! Your teaching skills are top
@Alex-rw9yj
@Alex-rw9yj 2 года назад
Thank you, man! Very clear and concise.
@666shadowblade666
@666shadowblade666 2 года назад
Again, exactly what I was needing to clarify. Thanks.
@Everyday-Explore
@Everyday-Explore 5 лет назад
Wonderful teacher. Clear precise and best..
@aakashrane8360
@aakashrane8360 3 года назад
Just half done with the video and just want to say WOW!!! Corey, try writing your own python book.
@grzltn9716
@grzltn9716 5 лет назад
Perfectly pitched overview. Thank you.
@peterdannemann2041
@peterdannemann2041 5 лет назад
Awesome content as always. Please make a video on asynchronous python programming!
@TheSumanb
@TheSumanb 3 года назад
Thanks a ton ... your way of teaching is one of the best , please keep on posting tutorials on pandas and Numpy or any advanced python topics , thanks
@billgarcia471
@billgarcia471 3 года назад
Thanks a lot for the video, man it's very helpful to explain some vague ideas from some modules.
@AlanWagoner
@AlanWagoner 5 лет назад
Very nice Corey! Thank you!
@madhusudhanreddy650
@madhusudhanreddy650 4 года назад
superbly explained,has none programmer can easily understand dif btwn Iterables and iterator
@szabikrdev5066
@szabikrdev5066 2 года назад
Cheers man, this was extremely useful piece of content!
@rainman13579
@rainman13579 3 года назад
Still being perfect explanation, there is still a need for preparation work to understand all the stuff Corey is explaining.
@temilolafamakinwa1626
@temilolafamakinwa1626 Год назад
Excellent explanations are always!!
@amardeepbhowmick3614
@amardeepbhowmick3614 4 года назад
Beautiful! Corey you da man!
@kentsang9376
@kentsang9376 3 года назад
very great video, clear my concept!! Thank you!
@rawlespringer3917
@rawlespringer3917 5 лет назад
wow you certainly have a gift for teaching...
@MauriceWilliams
@MauriceWilliams 4 года назад
Thanks Corey you delivered as usual.
@medi7573
@medi7573 5 лет назад
Great Tutorial.
@klo1603
@klo1603 5 лет назад
Had a long time issue in understanding this concept. You, Corey has always made easy to understand. Can you please make a series on selenium in python.
@wongkingshun
@wongkingshun Год назад
so what is iterator?
@calebthompson1037
@calebthompson1037 2 года назад
Classes in school should be like this a hyperlink to what you dont understand included. 💯
@NoksNeto
@NoksNeto 2 года назад
what a great lesson. thank you so much!
@panditnandlalpatherwali5979
@panditnandlalpatherwali5979 5 лет назад
Corey I am big fan of you videos, kindly post the video on pytest
@AshisRaj
@AshisRaj 2 года назад
My search ends here. Excellent explanation
@yiyanzhang2695
@yiyanzhang2695 5 лет назад
thanks , you explains so well
@johnwight6041
@johnwight6041 10 месяцев назад
Wow really good explanations! This makes a lot of sense
@dev4life
@dev4life 5 лет назад
Correction at 1:38 Corey said "Loops aren't the only thing that we can loop over " but he meant "Lists aren't the only thing that we can loop over "
@wasadasify
@wasadasify 4 года назад
gee thanks
@subhamthemusicalguy8851
@subhamthemusicalguy8851 4 года назад
Best video for Python.Thank you sir
@gustavojuantorena
@gustavojuantorena 2 года назад
This video is pure gold!
@ThatSic
@ThatSic 5 лет назад
Great video as always! Btw, I think you meant 'generator' instead of 'iterator' at 20:12 when you talked about memory effeciency.
@TonyFlexPromo
@TonyFlexPromo 5 лет назад
At first i was totally scared of iterators. Next i took a study and understood how do they work and why they are used. Next i wrote some iterators and generators on my own. Then i got a question about iterators on job interview and i was one of few people who actually answered the question (as they said later). Now i really love this feature of python and this is kinda future of it because whole async thing is based on yield thing. Thank you for videos! I continue to learn a lot from you!
@caseymccray3861
@caseymccray3861 5 лет назад
Love the idea of a password bruteforcer . Please make a video on it
@danielkamau8436
@danielkamau8436 3 года назад
good_tutor = "Corey Schafer" while True[good_tutor]: next(good_tutor) #looping forever sir thanks for expensive, but free endless knowledge. go beyond.
@Sabre00
@Sabre00 5 лет назад
From the time you mentioned the never ending generator and iterators not being able to be recalled it reminded me of a database auto-increment field. Just waiting for the timeseries MatplotLib video.
@sampleraja8026
@sampleraja8026 Год назад
He can make sense to even an absolute beginner, good
@utsavjolapara4366
@utsavjolapara4366 5 лет назад
Proper good job mate.
@bharadwajsaibandaru4323
@bharadwajsaibandaru4323 3 года назад
Hey Corey ! there you go . The best python instructor on RU-vid ever . Kudos to your subject knowledge and teaching in an easy and understandable way . Expecting JavaScript tutorials from you too.
@zuheyr1
@zuheyr1 3 года назад
Really great. Thank you!
@Borisam
@Borisam 2 года назад
Great explanation!!!
@veeek8
@veeek8 Год назад
thanks so much, great explaination
@rajgiriyt8494
@rajgiriyt8494 2 года назад
explaining each and every steps. where were you before. please do not leave this way of teaching. we beginners needs you
@yuanli5619
@yuanli5619 4 года назад
Best Python tutorial
@TheNormanbro
@TheNormanbro 4 года назад
Everytime when he says "dunder", i start to laugh because of "Dunder code" episode of The Office. And this is a great video. Thank you.
@2mitable
@2mitable 5 лет назад
thank you for this amazing video i have seen lot of videos from sentdex but still sometimes i did not understand as compare to you explanation Thank you very much you are helping like us soon i l help you i m trying to freelance in python thank you :D
@DASyam-tb7qt
@DASyam-tb7qt 5 лет назад
I used to listen to sentdex but after finding schafer, I found myself listening to schafer like 90% of the time. No hate to sentdex, tho. Subbed to both.
2 года назад
A video on unit testing iterables, generators, and, unit testing functions that consume iterable objects would be great.
@xlulu464
@xlulu464 4 года назад
finally i can try to understand why for loop is different from while loop. thanks
@franndyabreu6272
@franndyabreu6272 5 лет назад
Thank you.
@JuanCEOs725
@JuanCEOs725 11 месяцев назад
Simply the best!
@arjunkrishna721
@arjunkrishna721 3 года назад
you can technically get a reversed iterator, that'll look something like i_nums = reversed(nums) calling next(i_nums) will iterate through the list backwards. Much love, awesome teaching !
@pranavnyavanandi9710
@pranavnyavanandi9710 2 года назад
Hi. Do you mean reversed(i_nums)?
@deojeetsarkar2006
@deojeetsarkar2006 5 лет назад
this guy's a genius
@jessicabrown1987
@jessicabrown1987 4 года назад
Corey you are the best.
@CaptainBravo87
@CaptainBravo87 Год назад
Great explanation
@billykotsos4642
@billykotsos4642 4 года назад
Great Tutorial
@hirunahansaka646
@hirunahansaka646 5 месяцев назад
thank you very clear your explanation