HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
Infinidat
munch
Python2018–2021
Infinidat / munch

munch

A Munch is a Python dictionary that provides attribute-style access (a la JavaScript objects).

3Distinct people
3Mentions
1Explicit recommenders
785GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

A Munch is a Python dictionary that provides attribute-style access (a la JavaScript objects).

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

Highly recommend looking into Munch, "a dictionary that supports attribute-style access, a la JavaScript." https://github.com/Infinidat/munch In theory, implementing…

neoncontrails used a recommendation phrase. One indexed comment matches. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 5:04:57 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year3 dated mentions

Observed mentions: 2018-10-10 09:43:37 UTC to 2021-12-18 03:57:41 UTC.

0122018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20182019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments20192020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2021

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC101
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC000
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC000
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC202

What Hacker News says

3 sources
neoncontrails·Jul 20, 2021Recommendation phrase
Highly recommend looking into Munch, "a dictionary that supports attribute-style access, a la JavaScript." https://github.com/Infinidat/munch In theory, implementing attribute-style access on user-defined Python object is just a matter of overriding its __(get|set)attr__ methods, for example: In [1]: import collections In [2]: class DotDict(collections.UserDict): 2 def __getattr__(self, k): 3 try: 4 return self.__getitem__(k) 5 except: 6 return super().__getattribute__(k) 7 def __setattr__(self, k, v): 8 try: 9 self.__setitem__(k, v) 10 except Exception as e: 11 super().__setattr__(k,v) In [3]: d = DotDict({'a': 'b', 'c': [1,2,3], 'square': la
Read the rest
mbda x: x*x}) In [4]: d.square(4) Out[4]: 16 In [5]: d Out[5]: {'a': 'b', 'c': [1, 2, 3], 'square': <function <lambda> at 0x7f9ef5d5b0d0>} In [6]: import datetime In [7]: d.created_at = datetime.datetime.now() In [8]: d Out[8]: {'a': 'b', 'c': [1, 2, 3], 'square': <function <lambda> at 0x7f9ef5d5b0d0>, 'created_at': datetime.datetime(2021, 7, 19, 19, 42, 32, 341393)} In practice, this can lead to headaches. Take, for example, what happens if we try to serialize `d` (which has a non-serializable lambda function in its keys) using the built-in pickle module: In [9]: import pickle In [10]: pickle.dumps(d) Traceback (most recent call last): File "<stdin>", line 1, in <module> _pickle.PicklingError: Can't pickle <class 'DotDict'>: attribute lookup DotDict on builtins failed Thankfully there's a third-party library called cloudpickle which can serialize just about any python object to bytes -- even including the user-defined DotDict class (!): In [12]: deserialized_d = cloudpickle.loads(cloudpickle.dumps(d)) In [13]: deserialized_d Out[13]: {'a': 'b', 'c': [1, 2, 3], 'square': <function <lambda> at 0x7f9ef650fee0>, 'created_at': datetime.datetime(2021, 7, 19, 19, 42, 32, 341393)} Since the entire class definition is serialized along with the instance, the deserialized copy preserves the object's attribute-style interface as before: In [14]: deserialized_d.created_at.strftime("%c") Out[14]: 'Mon Jul 19 19:42:32 2021' But I recommend Munch over rolling your own because subclassing `dict` is fraught with a surprising number of edge cases.
In Brython: an implementation of Python 3 running in the browser

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.