diff --git a/README.md b/README.md index f31778f..b06d7c0 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,29 @@ Or you can use ``DefaultFactoryMunch`` to specify a factory for generating missi ``` +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 -------------