smpl.io

Simplified input and output.

files(folder, ending)

Get all the files in folder ending with ending.

find_file(fname[, up])

Searches for fname in all down folders or up folder to given order respectively.

gf([i])

Scientific number format.

mkdirs(fn)

Creates the neccessary directories above fn.

pr(a[, nnl])

Prints the passed a.

pwd()

Returns the path to the path of current file

write(destination, content)

Write to file by string or writable destiantion.

Functions

smpl.io.files(folder, ending)[source]

Get all the files in folder ending with ending.

smpl.io.find_file(fname, up=0)[source]

Searches for fname in all down folders or up folder to given order respectively.

smpl.io.gf(i=3)[source]

Scientific number format.

Parameters
iint

Number of digits.

Returns
str

Scientific number format string.

Examples

>>> gf(2)
'{0:.2g}'
>>> gf(2).format(789234578934)
'7.9e+11'
>>> gf(5).format(789234578934)
'7.8923e+11'
smpl.io.mkdirs(fn)[source]

Creates the neccessary directories above fn.

smpl.io.pr(a, nnl=False)[source]

Prints the passed a.

Parameters
nnlbool

no-new-line

Returns
aany

unchanged a.

Examples

>>> 5 + pr(4)
4
9
>>> 5 + pr(4, nnl=True)
49
smpl.io.pwd()[source]

Returns the path to the path of current file

smpl.io.write(destination, content)[source]

Write to file by string or writable destiantion.

Parameters
destinationstr,writeable

destination to write to.

contentstr

text to be written.

Examples

>>> write(sys.stdout,"hi")
hi
>>> write("test.out","hi")