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

4327

ubelt.Path

2125

ubelt.paragraph

1349

ubelt.ProgIter

747

ubelt.cmd

657

ubelt.codeblock

611

ubelt.udict

603

ubelt.expandpath

508

ubelt.take

462

ubelt.oset

342

ubelt.ddict

341

ubelt.iterable

313

ubelt.flatten

303

ubelt.group_items

287

ubelt.NiceRepr

270

ubelt.ensuredir

267

ubelt.map_vals

265

ubelt.peek

262

ubelt.NoParam

248

ubelt.dzip

239

ubelt.odict

236

ubelt.hash_data

200

ubelt.argflag

184

ubelt.grabdata

161

ubelt.dict_hist

156

ubelt.identity

156

ubelt.dict_isect

152

ubelt.Timer

145

ubelt.memoize

142

ubelt.argval

134

ubelt.allsame

133

ubelt.color_text

129

ubelt.schedule_deprecation

123

ubelt.augpath

120

ubelt.dict_diff

117

ubelt.IndexableWalker

116

ubelt.compress

116

ubelt.JobPool

107

ubelt.named_product

104

ubelt.hzcat

90

ubelt.delete

88

ubelt.unique

84

ubelt.WIN32

78

ubelt.dict_union

76

ubelt.symlink

76

ubelt.indent

69

ubelt.ensure_app_cache_dir

67

ubelt.iter_window

62

ubelt.invert_dict

58

ubelt.memoize_property

57

ubelt.import_module_from_name

56

ubelt.argsort

55

ubelt.timestamp

54

ubelt.modname_to_modpath

53

ubelt.find_duplicates

53

ubelt.hash_file

51

ubelt.find_exe

50

ubelt.map_keys

50

ubelt.dict_subset

50

ubelt.Cacher

49

ubelt.chunks

47

ubelt.sorted_vals

40

ubelt.CacheStamp

38

ubelt.highlight_code

37

ubelt.argmax

36

ubelt.writeto

36

ubelt.ensure_unicode

32

ubelt.sorted_keys

30

ubelt.memoize_method

29

ubelt.compatible

24

ubelt.import_module_from_path

24

ubelt.Executor

23

ubelt.readfrom

23

ubelt.modpath_to_modname

17

ubelt.AutoDict

17

ubelt.touch

17

ubelt.inject_method

14

ubelt.timeparse

13

ubelt.ChDir

11

ubelt.shrinkuser

11

ubelt.argmin

10

ubelt.varied_values

9

ubelt.split_modpath

8

ubelt.LINUX

8

ubelt.download

7

ubelt.NO_COLOR

7

ubelt.OrderedSet

6

ubelt.zopen

6

ubelt.CaptureStdout

6

ubelt.DARWIN

5

ubelt.boolmask

4

ubelt.find_path

4

ubelt.get_app_cache_dir

4

ubelt.indexable_allclose

3

ubelt.UDict

3

ubelt.SetDict

2

ubelt.AutoOrderedDict

2

ubelt.argunique

2

ubelt.map_values

1

ubelt.unique_flags

1

ubelt.userhome

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

0

ubelt.POSIX

0

ubelt.DownloadManager

0

ubelt.CaptureStream

0

usage stats = {
    'mean': 164.10257,
    'std': 467.12064,
    'min': 0.0,
    'max': 4327.0,
    'q_0.25': 6.0,
    'q_0.50': 50.0,
    'q_0.75': 134.0,
    'med': 50.0,
    'sum': 19200,
    'shape': (117,),
}

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.urepr> <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.ChDir>

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_repr

<ubelt.urepr> <ubelt.ReprExtensions>

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>

Package Layout

Indices and tables