https://i.imgur.com/PoYIsWE.png

UBelt documentation

UBelt is a “utility belt” of commonly needed utility and helper functions. It is a currated collection of top-level utilities with functionality that falls into a mixture of categories.

The source code is available at https://github.com/Erotemic/ubelt. We also have Jupyter notebook demos.

The ubelt API is organized by submodules containing related functionality. Each submodule contains top level overview documentation, and each function contains a docstring with at least one example.

NOTE: The README on github contains information and examples complementary to these docs.

The API by usefulness

Perhaps the most useful way to learn this API is to sort by “usefulness”. I measure usefulness as the number of times I’ve used a particular function in my own code (excluding ubelt itself).

Function name

Usefulness

ubelt.repr2

2001

ubelt.expandpath

728

ubelt.ProgIter

694

ubelt.ensuredir

539

ubelt.take

383

ubelt.odict

338

ubelt.map_vals

305

ubelt.dzip

272

ubelt.augpath

250

ubelt.ddict

227

ubelt.NiceRepr

220

ubelt.cmd

209

ubelt.flatten

206

ubelt.peek

189

ubelt.NoParam

184

ubelt.argval

179

ubelt.group_items

173

ubelt.argflag

173

ubelt.codeblock

171

ubelt.Timerit

164

ubelt.dict_hist

161

ubelt.iterable

144

ubelt.hash_data

124

ubelt.grabdata

106

ubelt.oset

103

ubelt.paragraph

100

ubelt.delete

97

ubelt.allsame

90

ubelt.compress

87

ubelt.color_text

84

ubelt.dict_subset

76

ubelt.dict_isect

75

ubelt.Cacher

70

ubelt.dict_diff

65

ubelt.memoize

54

ubelt.indent

54

ubelt.argsort

53

ubelt.Timer

52

ubelt.dict_union

50

ubelt.invert_dict

49

ubelt.identity

49

ubelt.find_duplicates

43

ubelt.map_keys

43

ubelt.timestamp

42

ubelt.unique

40

ubelt.chunks

38

ubelt.hzcat

37

ubelt.argmax

35

ubelt.import_module_from_path

35

ubelt.memoize_property

34

ubelt.iter_window

33

ubelt.readfrom

31

ubelt.sorted_vals

30

ubelt.hash_file

30

ubelt.writeto

30

ubelt.memoize_method

29

ubelt.symlink

28

ubelt.ensure_unicode

25

ubelt.CacheStamp

23

ubelt.touch

22

ubelt.modname_to_modpath

21

ubelt.find_exe

17

ubelt.import_module_from_name

17

ubelt.highlight_code

17

ubelt.AutoDict

13

ubelt.inject_method

11

ubelt.argmin

8

ubelt.shrinkuser

8

ubelt.split_modpath

6

ubelt.find_path

5

ubelt.download

5

ubelt.sorted_keys

5

ubelt.CaptureStdout

4

ubelt.modpath_to_modname

4

ubelt.userhome

3

ubelt.argunique

2

ubelt.AutoOrderedDict

1

ubelt.unique_flags

1

ubelt.varied_values

0

ubelt.platform_data_dir

0

ubelt.platform_config_dir

0

ubelt.named_product

0

ubelt.indexable_allclose

0

ubelt.get_app_data_dir

0

ubelt.get_app_config_dir

0

ubelt.ensure_app_data_dir

0

ubelt.ensure_app_config_dir

0

ubelt.compatible

0

ubelt.boolmask

0

ubelt.TempDir

0

ubelt.TeeStringIO

0

ubelt.POSIX

0

ubelt.OrderedSet

0

ubelt.NO_COLOR

0

ubelt.JobPool

0

ubelt.IndexableWalker

0

ubelt.FormatterExtensions

0

ubelt.Executor

0

ubelt.DownloadManager

0

ubelt.CaptureStream

0

usage stats = {
    'mean': 54.349514,
    'std': 147.71915,
    'min': 0.0,
    'max': 1426.0,
    'med': 19.0,
    'sum': 5598,
    'shape': (103,),
}

The following is a breakdown of the API by module

ubelt.orderedset

<ubelt.OrderedSet> <ubelt.oset>

ubelt.progiter

<ubelt.ProgIter>

ubelt.timerit

<ubelt.Timer> <ubelt.Timerit>

ubelt.util_arg

<ubelt.argval> <ubelt.argflag>

ubelt.util_cache

<ubelt.Cacher> <ubelt.CacheStamp>

ubelt.util_cmd

<ubelt.cmd>

ubelt.util_colors

<ubelt.NO_COLOR> <ubelt.highlight_code> <ubelt.color_text>

ubelt.util_const

<ubelt.NoParam>

ubelt.util_dict

<ubelt.AutoDict> <ubelt.AutoOrderedDict> <ubelt.dzip> <ubelt.ddict> <ubelt.dict_hist> <ubelt.dict_subset> <ubelt.dict_union> <ubelt.dict_isect> <ubelt.dict_diff> <ubelt.find_duplicates> <ubelt.group_items> <ubelt.invert_dict> <ubelt.map_keys> <ubelt.map_vals> <ubelt.sorted_keys> <ubelt.sorted_vals> <ubelt.odict> <ubelt.named_product> <ubelt.varied_values>

ubelt.util_download

<ubelt.download> <ubelt.grabdata>

ubelt.util_download_manager

<ubelt.DownloadManager>

ubelt.util_format

<ubelt.repr2> <ubelt.FormatterExtensions>

ubelt.util_func

<ubelt.identity> <ubelt.inject_method> <ubelt.compatible>

ubelt.util_futures

<ubelt.Executor> <ubelt.JobPool>

ubelt.util_hash

<ubelt.hash_data> <ubelt.hash_file>

ubelt.util_import

<ubelt.split_modpath> <ubelt.modname_to_modpath> <ubelt.modpath_to_modname> <ubelt.import_module_from_name> <ubelt.import_module_from_path>

ubelt.util_indexable

<ubelt.IndexableWalker> <ubelt.indexable_allclose>

ubelt.util_io

<ubelt.readfrom> <ubelt.writeto> <ubelt.touch> <ubelt.delete>

ubelt.util_list

<ubelt.allsame> <ubelt.argmax> <ubelt.argmin> <ubelt.argsort> <ubelt.argunique> <ubelt.boolmask> <ubelt.chunks> <ubelt.compress> <ubelt.flatten> <ubelt.iter_window> <ubelt.iterable> <ubelt.peek> <ubelt.take> <ubelt.unique> <ubelt.unique_flags>

ubelt.util_memoize

<ubelt.memoize> <ubelt.memoize_method> <ubelt.memoize_property>

ubelt.util_mixins

<ubelt.NiceRepr>

ubelt.util_path

<ubelt.TempDir> <ubelt.augpath> <ubelt.shrinkuser> <ubelt.userhome> <ubelt.ensuredir> <ubelt.expandpath>

ubelt.util_platform

<ubelt.WIN32> <ubelt.LINUX> <ubelt.DARWIN> <ubelt.POSIX> <ubelt.find_exe> <ubelt.find_path> <ubelt.ensure_app_cache_dir> <ubelt.ensure_app_config_dir> <ubelt.ensure_app_data_dir> <ubelt.get_app_cache_dir> <ubelt.get_app_config_dir> <ubelt.get_app_data_dir> <ubelt.platform_cache_dir> <ubelt.platform_config_dir> <ubelt.platform_data_dir>

ubelt.util_str

<ubelt.indent> <ubelt.codeblock> <ubelt.paragraph> <ubelt.hzcat> <ubelt.ensure_unicode>

ubelt.util_stream

<ubelt.TeeStringIO> <ubelt.CaptureStdout> <ubelt.CaptureStream>

ubelt.util_time

<ubelt.timestamp>

Indices and tables