From 52886ae59592cab9a09884a93db1f002f27e394a Mon Sep 17 00:00:00 2001 From: Clement Dumas Date: Tue, 16 Apr 2024 14:16:34 +0200 Subject: [PATCH 1/2] Added munchify to the readme --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index f31778f..5aa4104 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,31 @@ Or you can use ``DefaultFactoryMunch`` to specify a factory for generating missi ``` +Sure, I'd be happy to help you integrate your new content into the existing documentation. Here's your content, adapted to match the style and tone of the existing doc: + + +Converting an Existing Dictionary to Munch +------------------------------------------ + +If you have an existing dictionary that you've computed and want to convert it into a Munch object, you can use the `munchify` function. This function recursively transforms a dictionary into a Munch object via copy. Here's an example: + +```python +>>> b = munchify({'urmom': {'sez': {'what': 'what'}}}) +>>> b.urmom.sez.what +'what' +``` + +The `munchify` function can handle intermediary dicts, lists, and tuples (as well as their subclasses). However, your mileage may vary with custom data types. Here's a more complex example: + +```python +>>> b = munchify({ 'lol': ('cats', {'hah':'i win again'}), +... 'hello': [{'french':'salut', 'german':'hallo'}] }) +>>> b.hello[0].french +'salut' +>>> b.lol[1].hah +'i win again' +``` + Miscellaneous ------------- From d830164b35b9a22f46f0bc726d8d3b2263fa1703 Mon Sep 17 00:00:00 2001 From: Clement Dumas Date: Tue, 16 Apr 2024 14:19:13 +0200 Subject: [PATCH 2/2] fixed "typo" (I asked a llm to proofread what I wrote before adding it) --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 5aa4104..b06d7c0 100644 --- a/README.md +++ b/README.md @@ -159,8 +159,6 @@ Or you can use ``DefaultFactoryMunch`` to specify a factory for generating missi ``` -Sure, I'd be happy to help you integrate your new content into the existing documentation. Here's your content, adapted to match the style and tone of the existing doc: - Converting an Existing Dictionary to Munch ------------------------------------------