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

2621

ubelt.Path

903

ubelt.ProgIter

540

ubelt.paragraph

392

ubelt.take

385

ubelt.codeblock

330

ubelt.expandpath

330

ubelt.cmd

279

ubelt.ensuredir

258

ubelt.odict

255

ubelt.iterable

245

ubelt.udict

238

ubelt.ddict

234

ubelt.NoParam

220

ubelt.NiceRepr

219

ubelt.map_vals

216

ubelt.flatten

208

ubelt.dzip

201

ubelt.peek

197

ubelt.oset

191

ubelt.argflag

178

ubelt.group_items

169

ubelt.urepr

162

ubelt.hash_data

154

ubelt.grabdata

131

ubelt.Timer

120

ubelt.dict_isect

113

ubelt.dict_hist

112

ubelt.argval

110

ubelt.augpath

106

ubelt.identity

105

ubelt.ensure_app_cache_dir

105

ubelt.allsame

98

ubelt.memoize

97

ubelt.color_text

96

ubelt.dict_diff

95

ubelt.delete

89

ubelt.named_product

85

ubelt.compress

83

ubelt.schedule_deprecation

77

ubelt.IndexableWalker

72

ubelt.hzcat

68

ubelt.indent

68

ubelt.JobPool

65

ubelt.unique

63

ubelt.dict_union

57

ubelt.map_keys

49

ubelt.invert_dict

48

ubelt.timestamp

46

ubelt.iter_window

44

ubelt.argsort

44

ubelt.Cacher

43

ubelt.find_exe

41

ubelt.symlink

41

ubelt.dict_subset

41

ubelt.writeto

40

ubelt.chunks

39

ubelt.hash_file

37

ubelt.modname_to_modpath

37

ubelt.ensure_unicode

33

ubelt.sorted_vals

33

ubelt.memoize_property

33

ubelt.CacheStamp

32

ubelt.find_duplicates

32

ubelt.highlight_code

31

ubelt.WIN32

28

ubelt.import_module_from_name

27

ubelt.argmax

26

ubelt.readfrom

24

ubelt.import_module_from_path

21

ubelt.touch

17

ubelt.memoize_method

16

ubelt.Executor

15

ubelt.compatible

15

ubelt.sorted_keys

14

ubelt.shrinkuser

11

ubelt.AutoDict

10

ubelt.inject_method

10

ubelt.varied_values

9

ubelt.split_modpath

8

ubelt.modpath_to_modname

8

ubelt.get_app_cache_dir

8

ubelt.zopen

7

ubelt.LINUX

7

ubelt.CaptureStdout

6

ubelt.download

5

ubelt.timeparse

5

ubelt.DARWIN

5

ubelt.argmin

5

ubelt.find_path

4

ubelt.indexable_allclose

4

ubelt.boolmask

3

ubelt.map_values

2

ubelt.AutoOrderedDict

2

ubelt.argunique

2

ubelt.NO_COLOR

2

ubelt.UDict

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

0

ubelt.POSIX

0

ubelt.OrderedSet

0

ubelt.FormatterExtensions

0

ubelt.DownloadManager

0

ubelt.CaptureStream

0

usage stats = {
    'mean': 104.37607,
    'std': 265.43124,
    'min': 0.0,
    'max': 2621.0,
    'q_0.25': 5.0,
    'q_0.50': 37.0,
    'q_0.75': 106.0,
    'med': 37.0,
    'sum': 12212,
    '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.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>

Package Layout

Indices and tablesΒΆ