filmov
tv
Python Defaultdict Objects: Specialized Dictionaries With Initial Default Values 🐍 😍
Показать описание
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
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
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:
This code was extracted from an existing Python tip. To get 249 more of high quality Pythonic code tips, check out our book:
---
And last but not least, we appreciate any feedback to make our YouTube content better 💡
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
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
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:
This code was extracted from an existing Python tip. To get 249 more of high quality Pythonic code tips, check out our book:
---
And last but not least, we appreciate any feedback to make our YouTube content better 💡