smpl.io¶
Simplified input and output.
|
Appends to file by string or writable |
|
Get all the files in |
|
Searches for |
|
Scientific number format. |
|
Creates the neccessary directories above |
|
Prints the passed |
|
Returns the path to the path of current file (in linux format). |
|
Reads the file |
|
Write to file by string or writable |
Functions
- smpl.io.append(destination, content, mode='a+')[source]¶
Appends to file by string or writable
destiantion.Parameters¶
- destinationstr, writeable
destination to write to.
- contentstr
text to be written.
- modestr
mode to open the file. Default is ‘a+’ (append and read).
Examples¶
>>> append(sys.stdout,"hi") hi
- smpl.io.files(ending, folder='.')[source]¶
Get all the files in
folderending withending.Parameters¶
- folderstr
folder name.
- endingstr
ending of the files.
Returns¶
- list
list of files.
Examples¶
>>> files(".ini") [(0, 'pytest', './pytest.ini')]
- smpl.io.find_file(fname, up=0)[source]¶
Searches for
fnamein 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.Parameters¶
- fnstr
file name.
Examples¶
>>> mkdirs("test.out")
- 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 (in linux format).
Returns¶
- str
path to the path of current file.
- smpl.io.read(fname)[source]¶
Reads the file
fname.Parameters¶
- fnamestr
file name.
Returns¶
- str
content of the file.
Examples¶
>>> read("nonexistent.txt") '' >>> write("test.out","hi") >>> read("test.out") 'hi'
- smpl.io.remove(file)[source]¶
Removes
file.Parameters¶
- filestr
file name.
Examples¶
>>> remove("test.out")
- smpl.io.write(destination, content, mode='w+', create_dir=True)[source]¶
Write to file by string or writable
destiantion.Parameters¶
- destinationstr, writeable
destination to write to.
- contentstr
text to be written.
- modestr
mode to open the file. Default is ‘w+’ (write and read).
- create_dirbool
create directory if it does not exist.
Examples¶
>>> write(sys.stdout,"hi") hi >>> write("test.out","hi") >>> read("test.out") 'hi'