Make life easier

(int,object) -> func (float,object) -> func[source]

(int,object) -> func (float,object) -> func()

Dictionary-like object; __getitem__ matches keys of types using issubclass

Decorators

decorate_all_methods_with[source]

decorate_all_methods_with(decorators)

Decorate all methods of a class with a list of decorators

decorate_function_with[source]

decorate_function_with(decorators)

Apply a list of decorators to a function

Null Handling

coalesce[source]

coalesce(*args, default=None)

Provide same function as C# and JS ?? operator

Iterators

(int,object) -> func (float,object) -> func[source]

(int,object) -> func (float,object) -> func()

Dictionary-like object; __getitem__ matches keys of types using issubclass

# from fastcore.all import typedispatch
# import itertools
# from collections.abc import Iterable
# from nbdev.showdoc import * 

# @typedispatch
# def chunks(iterable:list, n:int=1) -> Iterable:
#     for ix in range(0, len(iterable), n):
#         yield iterable[ix: min(ix+n, len(iterable))]
        
# @typedispatch
# def chunks(iterable:Iterable, n:int=1) -> Iterable:
#     it = iter(iterable)
#     while True:
#         chunk_it = itertools.islice(it, n)
#         try:
#             first_el = next(chunk_it)
#         except StopIteration:
#             return
#         yield itertools.chain((first_el,), chunk_it)
        
# show_doc(chunks)
# from fastcore.all import typedispatch
# from collections.abc import Iterable

JSON

dict_generator[source]

dict_generator(indict, pre=None)

Recursively traverse a dictionary of unknown depth and return flat lists.

Useful for generating API endpoint strings from JSON-like

Misc

class DotDict[source]

DotDict(d) :: dict

Dot access that is not perfectly safe, but easier to work with when dealing with nested configs!

load_config[source]

load_config(config)

Load a yaml config file as a DotDict