knit_script.knit_script_interpreter.scope.variable_space module

Module containing the Variable_Space class.

class Variable_Space[source]

Bases: object

Tracks all the variables in a local scope with no protected attributes to accidentally override.

__init__()[source]

Initialize an empty variable space.

__contains__(variable_name)[source]
Parameters:

variable_name (str) – The name of the variable to check for existence.

Returns:

True if the variable exists, False otherwise.

Return type:

bool

__getitem__(variable_name)[source]
Parameters:

variable_name (str) – The name of the variable to access.

Returns:

The value of the variable.

Return type:

Any

Raises:

AttributeError – If the variable does not exist.

__setitem__(variable_name, value)[source]

Set a variable with the given variable name. Overrides any variable already defined by that variable name.

Parameters:
  • variable_name (str) – The name of the variable to set.

  • value (Any) – The value of the variable.

__delitem__(variable_name)[source]

Delete the variable with the given key name.

Parameters:

variable_name (str) – The name of the variable to delete.

Raises:

AttributeError – If the variable does not exist.