Table of Contents

session

`session` is a built-in global object for inspecting and managing Expr sessions.

A session stores root variables, user-defined functions, user-defined classes, and the last result for a named evaluation context.


Properties

Property Type Description
`current` string Name of the active session. The fallback session uses an empty name.
print(session.current);

Methods

list()

Returns session names separated by new lines.

print(session.list());

list_variables()

Returns variables in the current session, one per line.

print(session.list_variables());

list_functions_builtin()

Returns built-in function names, one per line.

list_classes_builtin()

Returns built-in object constructor names, one per line.

list_functions()

Returns user-defined function names in the current session.

list_classes()

Returns user-defined class names in the current session.

create(name)

Creates a new session named `name`, switches the current context to it, and returns an OK result. If the session already exists, returns an error result.

session.create('job1');
print(session.current);      // job1

delete(name)

Deletes the session named `name` and returns an OK result if it existed.

session.delete('old_job');

join(name)

Switches the current context to an existing session. If the session does not exist, an error is raised.

session.join('job1');

leave()

Switches the current context to the fallback empty-name session and returns an OK result.

session.leave();

clear()

Clears variables, user functions, and user classes from the current session. Built-in global objects are restored.

session.clear();

has_variable(sessionName, variableName)

Returns `true` if `sessionName` contains `variableName`.

exists = session.has_variable('job1', 'part_count');

get_variable(sessionName, variableName)

Returns a variable from another session. Object values must be cloneable.

count = session.get_variable('job1', 'part_count');

Previous: settings

Next: python