Skip to main content

IO

Convenience functions to process inputs and outputs.

Input

input (prompt, extract)

Wraps input() with an optional extract parameter to convert URLs to text

ParamTypeDescription
promptStringA String, representing a default message before the input.
extractBooleanTrue to extract the contents of URL as text, defaults to False. Requires the textract package to be installed.

Load

load (name, default, access)

Reload the contents stored with remember() with name.

ParamTypeDescription
nameStringThe file name of the file to load.
defaultObjectThe default object when file does not exists.

Returns the contents of name file, default if it does not exist.

Save

save (name, contents, hidden, files, encoding, access)

Saves as name the given contents. Useful to share binary files with users.

ParamTypeDescription
nameStringThe file name of the file to save.
contentsStringThe contents of the file to save.
hiddenBooleanTrue to hide file from user, defaults to False.
filesDictionaryA dictionary mapping additional file names to contents to save.
encodingStringThe encoding to use when saving text.
accessStringModify access level to user or shared. Defaults to storage to save file for current session. The shared level allows any user using this chat to access this file. The user level allows other sessions for the same user to access the file.

Saves to name file the given contents under the .storage subfolder. An appropriate extension for the name will be generated based on the type of contents.