bronx.syntax

Syntax useful tools.

Functions

bronx.syntax.dictmerge(d1, d2)[source]

Merge two dictionaries d1 and d2 with a recursive function.

  • d1 and d2 can be dictionaries of dictionaries;

  • The result is in d1. If keys exist in d1 and d2, d1 keys are replaced by d2 keys.

Examples:

>>> a = {'name':'clim','attr':{'model':{'values':('arpege','arome')}}}
>>> b = {'name':'clim model','attr':{'truncation':{'type':'int','optional':'False'}}}
>>> (dictmerge(a, b) ==
...  {'name': 'clim model', 'attr': {'model': {'values': ('arpege', 'arome')},
...                                  'truncation': {'type': 'int', 'optional': 'False'}}})
True

>>> (dictmerge({'a':'1'}, {'b':'2'}) ==
...  {'a': '1', 'b': '2'})
True

>>> (dictmerge({'a':'1','c':{'d':'3','e':'4'},'i':{'b':'2','f':{'g':'5'}}}, {'c':{'h':'6', 'e':'7'}}) ==
...  {'a': '1', 'i': {'b': '2', 'f': {'g': '5'}}, 'c': {'h': '6', 'e': '7', 'd': '3'}})
True
bronx.syntax.mktuple(obj)[source]

Make a tuple from any kind of object.

Sub-Modules

bronx.syntax.arrays

Numpy's useful tools.

bronx.syntax.decorators

Useful decorators.

bronx.syntax.externalcode

A handy class that checks that an external code import worked properly.

bronx.syntax.iterators

Useful iterators and associated tools..

bronx.syntax.minieval

Parse, check and execute single-line Python's statements.

bronx.syntax.parsing

Parsing tools.

bronx.syntax.pretty

Making things pretty.