Python's secret second argument to iter()

Опубликовано: 03 Октябрь 2024
на канале: mCoding
59,128
2.8k

Iter can take TWO args, lets take a look.

Did you know that Python's iter() builtin can actually take TWO arguments? This is a very obscure feature of Python. In this video we see how it differs from the very common single-argument form of iter(), how to use it, and what a better alternative is.

― mCoding with James Murphy (https://mcoding.io)

Source code: https://github.com/mCodingLLC/VideosS...
iter docs: https://docs.python.org/3/library/fun...
assignment expression docs: https://peps.python.org/pep-0572/

SUPPORT ME ⭐
---------------------------------------------------
Patreon:   / mcoding  
Paypal: https://www.paypal.com/donate/?hosted...
Other donations: https://mcoding.io/donate

Top patrons and donors: Jameson, Laura M, Vahnekie, Dragos C, Matt R, Casey G, Johan A, John Martin, Jason F, Mutual Information, Neel R

BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------
Discord:   / discord  
Github: https://github.com/mCodingLLC/
Reddit:   / mcoding  
Facebook:   / james.mcoding  

CHAPTERS
---------------------------------------------------
0:00 Intro
0:12 Single arg iter
1:17 Two arg iter
5:47 Walrus operator