package pyml
Install
Dune Dependency
Authors
Maintainers
Sources
sha512=462f86478a0131248805cc13d7eb4e5b4259241d9074e5ab00221018b7fe2d023a12ebf7ffcb81211ffca689fb6b065f251bd900e1925c481f98169e652ab6fa
doc/pyml/Pyutils/index.html
Module Pyutils
Source
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).
Returns the integer represented by the argument written in base 8.
Returns the integer represented by the argument written in base 16.
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
.
with_stdin_from_string s f arg
calls f arg
with the standard input redirected for reading from the contents of s
.