paint-brush
Filtering Dictionary In Python 3by@melvinkcx2
5,066 reads
5,066 reads

Filtering Dictionary In Python 3

by Melvin Koh6mJanuary 23rd, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

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.

Company Mentioned

Mention Thumbnail
featured image - Filtering Dictionary In Python 3
Melvin Koh HackerNoon profile picture
Melvin Koh

Melvin Koh

@melvinkcx2

Software Engineer | Maintainer of fastapi-events

About @melvinkcx2
LEARN MORE ABOUT @MELVINKCX2'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Melvin Koh HackerNoon profile picture
Melvin Koh@melvinkcx2
Software Engineer | Maintainer of fastapi-events

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite