Python's Magical Itertools Module

  Рет қаралды 79,229

Tech With Tim

Tech With Tim

Күн бұрын

Have you been missing something magical in your life lately? Well in this video I am going to be introducing you to a magical module called Itertools! This module is magical because it provides built in functionality, specifically functions for creating integrators for efficient looping! I hope you enjoy the video and find it magical!
💻 ProgrammingExpert is the best platform to learn how to code and become a software engineer as fast as possible! Check it out here: programmingexpert.io/tim and use code "tim" for a discount!
📄 Resources 📄
Itertools Documentation: docs.python.org/3/library/ite...
⭐️ Timestamps ⭐️
00:00 | Itertools Module
00:50 | What is An Iterators?
05:31 | Infinite Iterators
08:33 | Terminating Iterators
12:16 | Combinatoric Iterators
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
👕 Merchandise: teespring.com/stores/tech-wit...
📸 Instagram: / tech_with_tim
📱 Twitter: / techwithtimm
⭐ Discord: / discord
📝 LinkedIn: / tim-ruscica-82631b179
🌎 Website: techwithtim.net
📂 GitHub: github.com/techwithtim
🔊 Podcast: anchor.fm/tech-with-tim
🎬 My KZfaq Gear: www.techwithtim.net/gear/
💵 One-Time Donations: www.paypal.com/donate?hosted_...
💰 Patreon: / techwithtim
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
⭐️ Tags ⭐️
-Tech With Tim
-Itertools Module
-Magical Module
-Programming Module
-What is Itertools?
⭐️ Hashtags ⭐️
#TechWithTim #Itertools

Пікірлер: 72
@ray30k
@ray30k 2 жыл бұрын
Comment before watching: Itertools has been a life-saver for a bunch of programming puzzles/challenges I've done recently, and I'm happy to see it get a moment in the spotlight!
@leonardsmith9870
@leonardsmith9870 2 жыл бұрын
Correction: All of python is magic, there's literally libraries for everything you can imagine
@imaginecloudsxo7987
@imaginecloudsxo7987 2 жыл бұрын
YESSS I had a lecture on this 2 weeks ago but I forgot everything bc the lecturer rushed through it. So thankful for this video!
@strydomobile
@strydomobile 2 жыл бұрын
Hi Tim, I've purchased programming expert IO a week back. So far I'm hooked on it and the fact that the tests gives you a bit of creative freedom makes solving the challenges a lot more fun. Thanks for the effort you put into your craft. It really means a lot for people like me who cant afford to go back to university.
@TechWithTim
@TechWithTim 2 жыл бұрын
Thanks for the feedback Chiral! I’m so happy you’re enjoying it, I didn’t put a TON of work into it :)
@Redditard
@Redditard 2 жыл бұрын
Sus
@markwiygul6356
@markwiygul6356 2 жыл бұрын
Great work... You're videos are sharp and keep getting sharper!
@pravachanpatra4012
@pravachanpatra4012 2 жыл бұрын
Tim I loved the Django Authentication tutorial you made yesterday, can make more Django project tutorials?
@svantepanter
@svantepanter 2 жыл бұрын
Great video and walkthrough! Do you think one of the functions could be used as a part of a sudoku table-generator?
@tushensu
@tushensu 2 жыл бұрын
Great video Tim, I am buying the course today!!!!!
@Mehavenonameyet
@Mehavenonameyet 2 жыл бұрын
I have to say this was 'magical'. So many itertool fuctions I did not know about explained well. So many times I could have been using itertools rather than loops.
@excelwithmark
@excelwithmark 2 жыл бұрын
Love it love learning from each of your videos
@ITS_N3.LL.Y
@ITS_N3.LL.Y 2 жыл бұрын
Thank you for the great content men!
@Jacuav
@Jacuav 2 жыл бұрын
Never used this module before, thanks for bringing this up. I can definitely see this saving me a lot of time. Great work 👍
@JohnMitchellCalif
@JohnMitchellCalif 5 ай бұрын
super useful and clear! Subscribed
@user-cc8kb
@user-cc8kb 2 жыл бұрын
Great tutorial! Thanks! :)
@chessstudent8797
@chessstudent8797 2 жыл бұрын
Another information that I don't know about Python. Very impressive that they are codes that make it more easier lol
@francoisrioux5869
@francoisrioux5869 2 жыл бұрын
I work a lot with lists of nodes forming paths, knowing the pairwise function would have saved me a lot of headaches
@Jmignet
@Jmignet 2 жыл бұрын
That looks extremely useful! For the repeat and the chain (from_iterable) functions, I felt like they could be more easily achieved with comprehensions and simple list concatenation/appending. All, of that if the objects to be repeated would not be large enough as to worry about memory management. Is that the case or am I missing something? For a moment, I thought that the chain.from_iterable function could have some extra functionality by maybe "unpacking" a list within a list. But I tested and it was not the case: chain.from_iterable_example([[1, 2, 3], [4, 5, 6], [[7, 8, 9]]]) prints: [1, 2, 3, 4, 5, 6, [7, 8, 9]]
@gzbin365
@gzbin365 2 жыл бұрын
pairwise() only in python Version 3.10 and above
@sethdon1100
@sethdon1100 Жыл бұрын
In case your version don’t have it, here’s the source code that works: def pairwise(iterable): if len(iterable)
@tcgvsocg1458
@tcgvsocg1458 2 жыл бұрын
really good...can you do a video on screen video recorder but without using any modul or import?
@GAUTAMSHARMA-xu7bl
@GAUTAMSHARMA-xu7bl Жыл бұрын
Nice work.
@its_code
@its_code 2 жыл бұрын
Really informative 👍❤️❤️👌
@abab-ot7rn
@abab-ot7rn 2 жыл бұрын
Hello brother i have been watching u for like more than 2 years but i wanna know how u manages to learn many languages like c++,pytjon ,js simultaneously.. and u also learning many algo.and otjer concepts along with them.. could u pls share your ideas how u mamage all. And stil be the best at many things
@alexolson124
@alexolson124 2 жыл бұрын
Thanks mann!
@InspektorDreyfus
@InspektorDreyfus 2 жыл бұрын
Actually the term combinatronic sounds even more techie. 🤪
@chrysos
@chrysos 2 жыл бұрын
Isnt a normal calculation as efficient as a generator + list() ?
@SkyFly19853
@SkyFly19853 2 жыл бұрын
Nice!
@emanuelkokovics
@emanuelkokovics 2 жыл бұрын
But what if we implement everything you said but how it is internally implemented in python; then it will be as efficient.
@meesiphht2769
@meesiphht2769 2 жыл бұрын
Iter-done!!!!
@Betabdullah
@Betabdullah 2 жыл бұрын
Thanks
@alexybogomolov
@alexybogomolov 2 жыл бұрын
Combinatronic 😁
@sid.h
@sid.h 2 жыл бұрын
At 3:30, I think this is bad design. `for x in l` is usually interpreted as "for each item in l", a shorthand for a `for (int i = 0; i < l.size(); i++) {}` style loop. For me, coming from other languages, this would be an unexpected behaviour and I can imagine how it could lead to head-into-wall type bugs.
@nakedonthebeach
@nakedonthebeach 2 жыл бұрын
See also module "more_itertools" (installed best via pip).
@abbasdehghanzadeh5903
@abbasdehghanzadeh5903 2 жыл бұрын
Great:👍👍
@shujamukhtar4563
@shujamukhtar4563 2 жыл бұрын
Hi there Tim. Have you announced the 3080ti giveaway?
@bencipherx
@bencipherx 2 жыл бұрын
You mean in the iterator sequence 3:30
@Nathan-ng1kp
@Nathan-ng1kp 2 жыл бұрын
thank you core developers for "automating the boring stuff"
@first-thoughtgiver-of-will2456
@first-thoughtgiver-of-will2456 2 жыл бұрын
If you're really into the iterable collections paradigm I'd recommend Java (8 and beyond) and Rust in that order. In my experience these are the best iteration languages currently. Pythons list comprehension is interesting but without method chaining I feel python iterables are a little too verbose and less readable at a glance. Map reduce type lambda methods give you prior knowledge before you even know what the code does and that's very important in functional programming where things get abstracted very quickly and iterations where things get nested quickly.
@sid.h
@sid.h 2 жыл бұрын
One word. Kotlin! Kotlin kotlin kotlin kotlin kotlin.
@mahdinouira3261
@mahdinouira3261 Жыл бұрын
im new to python how can i make this work : class MyNumbers: def __init__(self, fname, lname): self.firstname = fname self.lastname = lname def __iter__(self): self.a = 1 return self def __next__(self): if self.a
@vinayakram5133
@vinayakram5133 2 жыл бұрын
Also need Tkinter , kivy tutorials tim....
@Songfugel
@Songfugel 2 жыл бұрын
This video is worth watching even just for the iterator introduction alone Very important point at 8:00 left unmentioned. In the case of for vs while ALWAYS use for in python if you can over while. While is the more generic of them and running on python, for however is a highly optimized C-implementation that is a LOT faster and efficient than using while.
@madhousenetwork7765
@madhousenetwork7765 2 жыл бұрын
Did "Nuttertools" cheat from GTA vice City strike for anyone?
@bhartiwadhwa9241
@bhartiwadhwa9241 2 жыл бұрын
Mann could please 🥺 make a video on machine learning in python would help soooooooo much. Thanks to you in advance😀
@TechWithTim
@TechWithTim 2 жыл бұрын
I have a bunch!
@fogsterded
@fogsterded 2 жыл бұрын
He actualy did 7h long video of ML… juste watch his channel
@bhartiwadhwa9241
@bhartiwadhwa9241 2 жыл бұрын
Ohhh well that's great actually thankyou for mentioning it😀🤩
@bhartiwadhwa9241
@bhartiwadhwa9241 2 жыл бұрын
@@TechWithTim Big fan of you brooo
@relytheone853
@relytheone853 2 жыл бұрын
You should use the inconsolata font on your editor.
@dragonsage6909
@dragonsage6909 2 жыл бұрын
Cool.. but yes, python is alwaus magical.. thanks!
@SosaiOyama
@SosaiOyama 2 жыл бұрын
So iterables are linked lists
@ryanyeager969
@ryanyeager969 2 жыл бұрын
python is the future
@U53RN07F0UND
@U53RN07F0UND 2 жыл бұрын
"Combinatronic" lol
@serta5727
@serta5727 2 жыл бұрын
Let’s see what it can do 🤓
@brettpeace9858
@brettpeace9858 2 жыл бұрын
Itertools is highly useful... The presenter needs to learn how to present though!!
@codeatemail
@codeatemail 2 жыл бұрын
love from India
@MrDazzlerdarren
@MrDazzlerdarren 2 жыл бұрын
Google the word "Iteration", it's my favourite Easter egg.
@danielzoref
@danielzoref 2 жыл бұрын
10
@illegalsmirf
@illegalsmirf 2 жыл бұрын
If all you want to do is print out 1 to 10, isn't there a simpler way to do it?
@richardbloemenkamp8532
@richardbloemenkamp8532 2 жыл бұрын
list is your friend to get around these annoying iterators and iteratables: print(list(range(1,11)))
@adiaphoros6842
@adiaphoros6842 2 жыл бұрын
If all you want to do is print 1 to 10, then a simple for loop using range() is enough. for i in range(10): print(i+1) Or if you want it the more “pythonic” way, use list comprehension: print([(i+1) for i in range(10)])
@illegalsmirf
@illegalsmirf 2 жыл бұрын
@@adiaphoros6842 I thought pythonic meant there is generally one way and not half a dozen ways of doing the same thing - which fills up the print with useless knowledge
@adiaphoros6842
@adiaphoros6842 2 жыл бұрын
@@illegalsmirf From what I read “pythonic” means “idiomatic in python,” which to me means “removing for loops through built-in functions.” But, I don’t know what I’m talking about, since I rarely program “pythonically,” because I’m more used to C, C#, and Java.
@kingleo429
@kingleo429 2 жыл бұрын
Python is technically programming god. It can do anything.
@illegalsmirf
@illegalsmirf 2 жыл бұрын
With Python you should never write anything from scratch, always import
@richardbloemenkamp8532
@richardbloemenkamp8532 2 жыл бұрын
The only thing you need to do is remember a few hundred libraries with a few hundred functions each. That is indeed much simpler ;~). But it will be more readable: Answer: No, only for other people who prefer memorizing the same libraries and functions. I did a test and most of my testers agree that it looks more elegant but when you ask them what the code actually does you get fewer correct answers. But the performance is better if you do that. Answer: If you need performance you better skip Python altogether. But it has great function like permutations and combinations. Answer, when was the last time you actually programmed permutation or combinations of lists? Most programmers never use them. I more or less agree with Linus Torvalds that the C syntax is enough.
@xlerb_again_to_music7908
@xlerb_again_to_music7908 2 жыл бұрын
Tim, too fast. Loading up pupils with stuff you know @ speed you narrate allows no time for their cognition i.e. internally comprehend and absorb new learning. Suggest building in breaks of some form, so they can process what is going on.
@unknownman5296
@unknownman5296 2 жыл бұрын
is this an April fools day video ??
@fustigate8933
@fustigate8933 2 жыл бұрын
Thanks
@abbasdehghanzadeh5903
@abbasdehghanzadeh5903 2 жыл бұрын
Great:👍👍
10 Python Shortcuts You Need To Know
27:27
Tech With Tim
Рет қаралды 291 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 408 М.
NERF WAR HEAVY: Drone Battle!
00:30
MacDannyGun
Рет қаралды 44 МЛН
MEU IRMÃO FICOU FAMOSO
00:52
Matheus Kriwat
Рет қаралды 44 МЛН
Heartwarming: Stranger Saves Puppy from Hot Car #shorts
00:22
Fabiosa Best Lifehacks
Рет қаралды 18 МЛН
The child was abused by the clown#Short #Officer Rabbit #angel
00:55
兔子警官
Рет қаралды 23 МЛН
Async for loops in Python
16:36
mCoding
Рет қаралды 58 М.
5 Tips To Organize Python Code
12:16
Tech With Tim
Рет қаралды 219 М.
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1,1 МЛН
Python Generators
15:32
mCoding
Рет қаралды 131 М.
Python Generators Explained
28:37
Tech With Tim
Рет қаралды 146 М.
You Can Do Really Cool Things With Functions In Python
19:47
ArjanCodes
Рет қаралды 217 М.
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
pixegami
Рет қаралды 247 М.
Python Pwntools Hacking: ret2libc GOT & PLT
44:49
John Hammond
Рет қаралды 46 М.
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 71 М.
NERF WAR HEAVY: Drone Battle!
00:30
MacDannyGun
Рет қаралды 44 МЛН