Comments (2)
DefaultMunch
only works for constants, not functions/classes. You should use DefaultFactoryMunch
instead:
from munch import DefaultFactoryMunch
#from collections import defaultdict
import sys; print(sys.version)
import munch; print(munch.__version__)
s = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)]
#d = defaultdict(list)
d = DefaultFactoryMunch(list)
for k, v in s: d[k].append(v)
print(sorted(d.items()))
output:
3.8.6 (default, Jan 4 2021, 19:49:33)
[Clang 12.0.0 (clang-1200.0.32.27)]
2.5.0
[('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
from munch.
Thank you.
from munch.
Related Issues (20)
- DefaultMunch getter now returns None instead of DefaultValue HOT 2
- munch.fromYAML issue HOT 1
- is Munch thread safe for reading? HOT 1
- Setup.py Update HOT 1
- Recursive dict merge HOT 2
- What are the recommended type annotations? HOT 9
- Undeclared dependency on setuptools (pkg_resources) HOT 3
- _make is part of namedtuple's contract, not tuple HOT 2
- A warning/error should be given if an element has the key "items" HOT 1
- version parsing HOT 1
- Cannot import Munch if the wheel doesn't come from a regular source HOT 1
- Describe Installation / Link out to Pypi page HOT 1
- New version on PyPi with RecursiveMunch HOT 4
- Munch cannot recursively fetch values beyond first level when passed with a dot notation. HOT 2
- mucnh does not seem to work when called using python's exec method HOT 1
- Munch does not support local version identifiers
- Make `munch.Munch` a Generic and add type annotations
- munchify broken?
- Need exception thrown for missing attributes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from munch.