common

EPS

Double-precision floating-point number type, compatible with Python float and C double.

add_to_config(config, info)

Add sections and key-val paris in info to config.

asseq(arg)

Assert arg to be a sequence.

assert_cond(cond[, string])

Use this instead of assert cond, string.

backtick(call)

Convenient shell backtick replacement.

backup(src[, prefix])

Backup (copy) src to <src><prefix><num>, where <num> is an integer starting at 0 which is incremented until there is no destination with that name.

cpickle_load(filename)

Load object written by cPickle.dump().

dict2class(dct[, name])

Convert a dict to a class.

dict2str(dct)

Nicer than simply __repr__.

ffloat(st)

Convert strings representing numbers to Python floats using float().

file_read(fn)

Open file with name fn, return open(fn).read().

file_readlines(fn)

Open file with name fn, return open(fn).readlines().

file_template_replace(fn, dct[, bak])

Replace placeholders in file fn.

file_write(fn, txt)

Write string txt to file with name fn.

fix_eps(arr[, eps, copy])

Set values of arr to zero where abs(arr) <= eps.

flatten(seq)

Same as iflatten(), but returns a list.

fpj(*args)

frepr(var[, ffmt])

Similar to Python's repr(), but return floats formated with ffmt if var is a float.

fullpath(s)

Complete path: absolute path + $HOME expansion.

fullpathjoin(*args)

get_filename(fh)

Try to get the name attribute from file-like objects.

iflatten(seq)

Flatten a sequence.

is_seq(seq)

Test if seq is some kind of sequence, based on calling iter(seq), i.e. if the object is iterable.

makedirs(path)

Same as os.makedirs() but silently skips empty paths.

permit_sigpipe()

Helper for subprocess.Popen().

pop_from_list(lst, items)

Pop all items from lst and return a shorter copy of lst.

print_dct(dct)

seq2str(seq[, func, sep])

(1,2,3) -> "1 2 3"

str2seq(st[, func, sep])

"1 2 3" -> [func('1'), func('2'), func('3')]

str2tup(*args, **kwargs)

str_arr(arr[, fmt, delim, zero_eps, eps])

Convert array arr to nice string representation for printing.

system(call[, wait])

Fire up shell commamd line call.

template_replace(txt, dct[, conv, ...])

Replace placeholders dct.keys() with string values dct.values() in a text string.

tobool(val)

Convert val to boolean value True or False.

toslice(val)

A simple wrapper around numpy.s_() taking strings as argument.

tup2str(seq[, func, sep])

(1,2,3) -> "1 2 3"