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 🙏
En esta página del sitio puede ver el video en línea Python Defaultdict Objects: Specialized Dictionaries With Initial Default Values 🐍 😍 de Duración hora minuto segunda en buena calidad , que subió el usuario Pybites 27 julio 2023, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 240 veces y le gustó 13 a los espectadores. Disfruta viendo!