python itertools

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2024 Jul 12 12:41
Editor
Edited
Edited
2024 Nov 1 1:18
  • repeat (repeat sequence finitely)
  • cycle (repeat sequence infinitely)
  • accumulate (reduce but return all intermediates)
python itertools members
 
 
 
Python itertools - The key to mastering iteration
The key to iteration in Python A key feature of Python is it's incredible support for lazy iteration. Defining and consuming lazy sequences in Python are easy. You can even define an infinite sequence like powers of 2 or prime numbers! To make working with iterables in Python even easier, Python provides some basic building blocks to help you compose iteration primitives in different ways, which is what the itertools module is for. This module comes with 21 different primitives (and many more recipes for how to combine them), which we go over in this video. Will you use them? ― mCoding with James Murphy (https://mcoding.io) Docs: https://docs.python.org/3/library/itertools.html Source code: https://github.com/mCodingLLC/VideosSampleCode SUPPORT ME ⭐ --------------------------------------------------- Sign up on Patreon to get your donor role and early access to videos! https://patreon.com/mCoding Feeling generous but don't have a Patreon? Donate via PayPal! (No sign up needed.) https://www.paypal.com/donate/?hosted_button_id=VJY5SLZ8BJHEE Want to donate crypto? Check out the rest of my supported donations on my website! https://mcoding.io/donate Top patrons and donors: Laura M, Jameson, Dragos C, Vahnekie, Neel R, Matt R, Johan A, Casey G, Mark M, Mutual Information, Pi BE ACTIVE IN MY COMMUNITY 😄 --------------------------------------------------- Discord: https://discord.gg/Ye9yJtZQuN Github: https://github.com/mCodingLLC/ Reddit: https://www.reddit.com/r/mCoding/ Facebook: https://www.facebook.com/james.mcoding CHAPTERS --------------------------------------------------- 0:00 Intro 1:47 An initial warning 2:30 Lookahead motivating multi-accumulate 3:09 ALL 21 ITERTOOLS - itertools.count 3:41 itertools.cycle 4:01 itertools.repeat 4:17 itertools.accumulate 4:58 itertools.batched 5:28 itertools.chain 5:58 itertools.chain.from_iterable 6:18 itertools.compress 6:42 itertools.dropwhile 7:32 itertools.filterfalse 8:18 itertools.groupby 10:08 itertools.islice 11:04 itertools.pairwise 11:47 itertools.starmap 12:43 itertools.takewhile 13:02 itertools.tee 14:22 itertools.zip_longest 14:48 itertools.product 15:43 itertools.permutations 16:15 itertools.combinations 16:55 itertools.combinations_with_replacement 17:22 multi_accumulate example 19:43 Thanks
Python itertools - The key to mastering iteration
 
 
 

Recommendations