Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
This module declares utility functions that does not require Python to be initialized.
substring_between s i j
returns the substring of s
between the indices i
(included) and j
(excluded).
If the character occurs in the substring beginning from from
, returns the prefix that precedes the first occurrence (excluded), else returns the whole substring beginning from from
.
If the character occurs in the substring beginning from from
, returns the suffix that succedes the first occurrence (excluded), else returns the whole substring beginning from from
.
If the string ends with '\r'
, then returns the string without this character, else returns the whole string.
Reads and returns all the lines from an input channel to the end of file. Carriage return characters are removed from the end of lines if any.
option_find f x
returns Some (f x)
, or None
if f x
raises Not_found
.
write_and_close channel f arg
calls f arg
, and returns the result of f
. channel
is always closed after f
has been called, even if f
raises an exception.
with_temp_file s f
creates a temporary file with s
as contents and calls f filename in_channel
where filename
is the name of the temporary file and in_channel
is an input channel opened to read the file. The file is deleted after the execution of f
(even if f
raised an exception.
with_pipe f
creates a pipe and calls f
with the two ends of the pipe.
with_stdin_from chan f arg
calls f arg
with the standard input redirected for reading from chan
.
with_channel_from_string s f
calls f in_channel
where in_channel
is an input channel returning the contents of s
.