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

2373

ubelt.ProgIter

466

ubelt.take

343

ubelt.expandpath

338

ubelt.ensuredir

261

ubelt.paragraph

239

ubelt.map_vals

237

ubelt.cmd

234

ubelt.odict

231

ubelt.Path

222

ubelt.NiceRepr

205

ubelt.ensure_app_cache_dir

204

ubelt.iterable

201

ubelt.codeblock

200

ubelt.NoParam

196

ubelt.flatten

190

ubelt.peek

185

ubelt.ddict

172

ubelt.dzip

162

ubelt.group_items

154

ubelt.oset

132

ubelt.hash_data

128

ubelt.argflag

123

ubelt.grabdata

116

ubelt.augpath

109

ubelt.Timer

105

ubelt.dict_isect

104

ubelt.dict_diff

98

ubelt.argval

97

ubelt.allsame

96

ubelt.dict_hist

94

ubelt.delete

90

ubelt.identity

88

ubelt.color_text

85

ubelt.compress

83

ubelt.hzcat

75

ubelt.memoize

70

ubelt.named_product

52

ubelt.dict_union

48

ubelt.map_keys

43

ubelt.invert_dict

43

ubelt.JobPool

41

ubelt.hash_file

38

ubelt.unique

38

ubelt.timestamp

38

ubelt.indent

38

ubelt.argsort

37

ubelt.IndexableWalker

36

ubelt.Cacher

36

ubelt.dict_subset

35

ubelt.iter_window

34

ubelt.memoize_property

34

ubelt.writeto

32

ubelt.sorted_vals

31

ubelt.find_exe

30

ubelt.ensure_unicode

29

ubelt.chunks

29

ubelt.find_duplicates

29

ubelt.CacheStamp

28

ubelt.memoize_method

24

ubelt.argmax

24

ubelt.import_module_from_path

24

ubelt.symlink

21

ubelt.readfrom

21

ubelt.WIN32

20

ubelt.highlight_code

20

ubelt.import_module_from_name

19

ubelt.modname_to_modpath

17

ubelt.touch

17

ubelt.get_app_cache_dir

16

ubelt.Executor

13

ubelt.sorted_keys

12

ubelt.inject_method

10

ubelt.compatible

8

ubelt.AutoDict

8

ubelt.shrinkuser

8

ubelt.find_path

7

ubelt.LINUX

7

ubelt.CaptureStdout

6

ubelt.modpath_to_modname

6

ubelt.argmin

5

ubelt.zopen

4

ubelt.varied_values

4

ubelt.split_modpath

4

ubelt.DARWIN

4

ubelt.userhome

3

ubelt.download

3

ubelt.argunique

2

ubelt.AutoOrderedDict

1

ubelt.unique_flags

1

ubelt.split_archive

0

ubelt.platform_data_dir

0

ubelt.platform_config_dir

0

ubelt.platform_cache_dir

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.boolmask

0

ubelt.TempDir

0

ubelt.TeeStringIO

0

ubelt.POSIX

0

ubelt.OrderedSet

0

ubelt.NO_COLOR

0

ubelt.FormatterExtensions

0

ubelt.DownloadManager

0

ubelt.CaptureStream

0

usage stats = {
    'mean': 89.296295,
    'std': 238.03113,
    'min': 0.0,
    'max': 2373.0,
    'q_0.25': 4.75,
    'q_0.50': 30.5,
    'q_0.75': 99.5,
    'med': 30.5,
    'sum': 9644,
    'shape': (108,),
}

ubelt.orderedset

<ubelt.OrderedSet> <ubelt.oset>

ubelt.progiter

<ubelt.ProgIter>

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.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> <ubelt.Timer>

ubelt.util_zip

<ubelt.zopen> <ubelt.split_archive>

Indices and tables