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

1956

ubelt.take

247

ubelt.ProgIter

227

ubelt.odict

201

ubelt.iterable

189

ubelt.NiceRepr

188

ubelt.NoParam

183

ubelt.ensuredir

155

ubelt.map_vals

154

ubelt.dzip

144

ubelt.codeblock

133

ubelt.cmd

131

ubelt.flatten

125

ubelt.Timerit

122

ubelt.peek

112

ubelt.ddict

109

ubelt.grabdata

102

ubelt.argflag

102

ubelt.paragraph

102

ubelt.expandpath

101

ubelt.hash_data

86

ubelt.argval

86

ubelt.allsame

85

ubelt.oset

83

ubelt.group_items

78

ubelt.hzcat

75

ubelt.color_text

69

ubelt.Timer

60

ubelt.dict_hist

60

ubelt.delete

54

ubelt.identity

53

ubelt.dict_isect

50

ubelt.compress

50

ubelt.dict_diff

49

ubelt.map_keys

41

ubelt.memoize

38

ubelt.invert_dict

36

ubelt.indent

35

ubelt.named_product

30

ubelt.hash_file

30

ubelt.iter_window

30

ubelt.memoize_property

30

ubelt.writeto

28

ubelt.argsort

27

ubelt.ensure_unicode

26

ubelt.augpath

26

ubelt.sorted_vals

26

ubelt.dict_union

25

ubelt.unique

25

ubelt.Cacher

25

ubelt.chunks

23

ubelt.import_module_from_path

23

ubelt.find_exe

21

ubelt.CacheStamp

21

ubelt.IndexableWalker

20

ubelt.dict_subset

20

ubelt.timestamp

19

ubelt.readfrom

19

ubelt.JobPool

18

ubelt.import_module_from_name

18

ubelt.argmax

18

ubelt.memoize_method

17

ubelt.touch

16

ubelt.modname_to_modpath

15

ubelt.find_duplicates

14

ubelt.highlight_code

10

ubelt.symlink

8

ubelt.find_path

7

ubelt.inject_method

7

ubelt.shrinkuser

7

ubelt.modpath_to_modname

6

ubelt.CaptureStdout

5

ubelt.argmin

5

ubelt.split_modpath

4

ubelt.compatible

4

ubelt.download

3

ubelt.AutoDict

3

ubelt.argunique

2

ubelt.sorted_keys

2

ubelt.AutoOrderedDict

1

ubelt.Executor

1

ubelt.unique_flags

1

usage stats = {
    'mean': 79.96342,
    'std': 216.54169,
    'min': 1.0,
    'max': 1956.0,
    'med': 30.0,
    'sum': 6557,
    'shape': (82,),
}

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

<ubelt.zopen> <ubelt.split_archive>

Indices and tables