TLDR
Python slaps you in your face when you try to add/remove entries in a dictionary during iteration during iteration. In this post, I will walk us through how we can filter a dict for a dictionary in Python. I decided to use a copy of dictionary keys to mitigate the problem when attempting to delete entries during iteration. Let’s make use of our FilterableDict, a reusable class to support filtering. In the subsequent part of this post I will use the former to illustrate how we could make our filter logic reusable.via the TL;DR App
no story
Written by melvinkcx2 | Software Engineer | Maintainer of fastapi-events