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

2387

ubelt.ProgIter

454

ubelt.take

358

ubelt.expandpath

341

ubelt.ensuredir

299

ubelt.odict

297

ubelt.dzip

244

ubelt.NiceRepr

238

ubelt.map_vals

229

ubelt.flatten

214

ubelt.cmd

208

ubelt.ddict

199

ubelt.NoParam

184

ubelt.peek

182

ubelt.codeblock

174

ubelt.argflag

171

ubelt.paragraph

154

ubelt.argval

147

ubelt.iterable

143

ubelt.group_items

141

ubelt.grabdata

128

ubelt.oset

115

ubelt.hash_data

115

ubelt.color_text

115

ubelt.augpath

103

ubelt.dict_hist

102

ubelt.delete

100

ubelt.compress

99

ubelt.dict_isect

86

ubelt.dict_diff

84

ubelt.allsame

80

ubelt.Timer

80

ubelt.hzcat

71

ubelt.identity

71

ubelt.invert_dict

60

ubelt.map_keys

51

ubelt.Cacher

49

ubelt.memoize

47

ubelt.argsort

45

ubelt.chunks

43

ubelt.dict_union

43

ubelt.dict_subset

43

ubelt.indent

43

ubelt.unique

41

ubelt.ensure_unicode

40

ubelt.writeto

40

ubelt.sorted_vals

38

ubelt.hash_file

37

ubelt.iter_window

37

ubelt.timestamp

37

ubelt.find_duplicates

33

ubelt.named_product

29

ubelt.argmax

28

ubelt.memoize_property

28

ubelt.find_exe

24

ubelt.readfrom

24

ubelt.IndexableWalker

23

ubelt.symlink

23

ubelt.JobPool

22

ubelt.memoize_method

22

ubelt.touch

21

ubelt.CacheStamp

21

ubelt.import_module_from_path

21

ubelt.modname_to_modpath

20

ubelt.import_module_from_name

19

ubelt.highlight_code

19

ubelt.inject_method

15

ubelt.shrinkuser

13

ubelt.sorted_keys

11

ubelt.AutoDict

9

ubelt.compatible

8

ubelt.find_path

7

ubelt.Executor

7

ubelt.split_modpath

6

ubelt.argmin

6

ubelt.CaptureStdout

5

ubelt.varied_values

4

ubelt.modpath_to_modname

4

ubelt.download

3

ubelt.zopen

2

ubelt.AutoOrderedDict

2

ubelt.argunique

2

ubelt.unique_flags

2

ubelt.userhome

1

ubelt.boolmask

1

ubelt.split_archive

0

ubelt.platform_data_dir

0

ubelt.platform_config_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.TempDir

0

ubelt.TeeStringIO

0

ubelt.Path

0

ubelt.POSIX

0

ubelt.OrderedSet

0

ubelt.NO_COLOR

0

ubelt.FormatterExtensions

0

ubelt.DownloadManager

0

ubelt.CaptureStream

0

usage stats = {
    'mean': 91.56311,
    'std': 244.67274,
    'min': 0.0,
    'max': 2387.0,
    'med': 33.0,
    'sum': 9431,
    'shape': (103,),
}

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