Python Defaultdict Objects: Specialized Dictionaries With Initial Default Values 🐍 😍

Publicado em: 27 Julho 2023
no canal de: Pybites
240
13

Today a quick video about defaultdict objects ( from the collections module).

We work through a practical example where a regular dict falls short / requires extra code you can prevent writing when using this specialized container type 💪

Chapters:
00:00 What is a defaultdict (collections module)?
00:21 Practical example
00:38 Parse the data
01:10 Using a regular dict leads to issues
02:10 Clumsy workaround
02:46 Checking if dict content is correct
03:17 Adding an assert
03:45 An alternative: dict.setdefault()
04:24 The better way: defaultdict
04:58 Recap
05:20 Using it with other factory methods (set)A
06:25 Related videos and wrap up

Docs: https://docs.python.org/3/library/col...

Practice!
Here is a promo code (valid for 1 week, till the 3rd of Aug 2023) for an intermediate Pybites exercise where you can use what you've learned in this video:
https://codechalleng.es/bites/promo/d...

This code was extracted from an existing Python tip. To get 249 more of high quality Pythonic code tips, check out our book:
http://pybit.es/tips

---
Learn more about Pybites / what we do: https://pybit.es

Get our weekly developer / mindset emails: https://pybit.es/friends/

Join our Slack community: https://pybit.es/community/

And last but not least, we appreciate any feedback to make our YouTube content better 💡
https://form.jotform.com/230941798741062 🙏


Nesta página do site você pode assistir ao vídeo on-line Python Defaultdict Objects: Specialized Dictionaries With Initial Default Values 🐍 😍 duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Pybites 27 Julho 2023, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 240 vezes e gostou 13 espectadores. Boa visualização!