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

2384

ubelt.Path

624

ubelt.ProgIter

539

ubelt.expandpath

419

ubelt.paragraph

358

ubelt.take

342

ubelt.cmd

283

ubelt.codeblock

273

ubelt.ensuredir

252

ubelt.map_vals

248

ubelt.odict

234

ubelt.ddict

225

ubelt.flatten

218

ubelt.peek

202

ubelt.ensure_app_cache_dir

201

ubelt.NiceRepr

195

ubelt.group_items

192

ubelt.oset

182

ubelt.dzip

169

ubelt.iterable

159

ubelt.dict_isect

157

ubelt.NoParam

154

ubelt.hash_data

141

ubelt.argflag

136

ubelt.dict_diff

129

ubelt.Timer

125

ubelt.augpath

120

ubelt.dict_hist

115

ubelt.grabdata

114

ubelt.color_text

104

ubelt.identity

102

ubelt.delete

99

ubelt.argval

93

ubelt.dict_union

90

ubelt.memoize

89

ubelt.compress

87

ubelt.allsame

81

ubelt.unique

64

ubelt.named_product

61

ubelt.hzcat

61

ubelt.invert_dict

61

ubelt.JobPool

60

ubelt.timestamp

48

ubelt.dict_subset

46

ubelt.Cacher

44

ubelt.indent

44

ubelt.argsort

43

ubelt.IndexableWalker

41

ubelt.writeto

41

ubelt.iter_window

40

ubelt.chunks

39

ubelt.hash_file

38

ubelt.find_duplicates

38

ubelt.map_keys

36

ubelt.symlink

34

ubelt.sorted_vals

33

ubelt.ensure_unicode

32

ubelt.find_exe

32

ubelt.memoize_property

31

ubelt.modname_to_modpath

29

ubelt.WIN32

28

ubelt.CacheStamp

27

ubelt.import_module_from_name

25

ubelt.argmax

23

ubelt.highlight_code

23

ubelt.varied_values

22

ubelt.readfrom

22

ubelt.import_module_from_path

21

ubelt.compatible

20

ubelt.memoize_method

20

ubelt.sorted_keys

20

ubelt.Executor

19

ubelt.touch

17

ubelt.get_app_cache_dir

14

ubelt.AutoDict

13

ubelt.inject_method

13

ubelt.zopen

11

ubelt.shrinkuser

11

ubelt.userhome

8

ubelt.schedule_deprecation

8

ubelt.LINUX

8

ubelt.split_modpath

7

ubelt.modpath_to_modname

7

ubelt.CaptureStdout

5

ubelt.DARWIN

5

ubelt.argmin

4

ubelt.download

3

ubelt.find_path

2

ubelt.AutoOrderedDict

2

ubelt.argunique

1

ubelt.unique_flags

1

ubelt.udict

0

ubelt.timeparse

0

ubelt.split_archive

0

ubelt.sorted_values

0

ubelt.sdict

0

ubelt.platform_data_dir

0

ubelt.platform_config_dir

0

ubelt.platform_cache_dir

0

ubelt.map_values

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

0

ubelt.TempDir

0

ubelt.TeeStringIO

0

ubelt.SetDict

0

ubelt.POSIX

0

ubelt.OrderedSet

0

ubelt.NO_COLOR

0

ubelt.FormatterExtensions

0

ubelt.DownloadManager

0

ubelt.CaptureStream

0

usage stats = {
    'mean': 95.18104,
    'std': 240.17876,
    'min': 0.0,
    'max': 2384.0,
    'q_0.25': 2.75,
    'q_0.50': 31.5,
    'q_0.75': 106.5,
    'med': 31.5,
    'sum': 11041,
    'shape': (116,),
}

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_deprecate

<ubelt.schedule_deprecation>

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.map_values> <ubelt.sorted_keys> <ubelt.sorted_vals> <ubelt.sorted_values> <ubelt.odict> <ubelt.named_product> <ubelt.varied_values> <ubelt.SetDict> <ubelt.UDict> <ubelt.sdict> <ubelt.udict>

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

ubelt.util_zip

<ubelt.zopen> <ubelt.split_archive>

Indices and tables