top of page
The environment

As with any other shell, marcel has environment variables. In Python terms, these variables exist in a Python namespace that is made available to marcel commands. So, for example, you can examine the value of the HOME variable as follows:

M 0.18.3 jao@loon ~/git/marcel$ (HOME)

The parentheses delimit the Python expression HOME. That symbol is located in marcel's namespace (the environment), and the value is printed.

You can create or modify environment variables by using conventional assignment syntax. The following example assigns the integer 123 to the variable x, and then prints out the value of the variable.

M 0.18.3 jao@loon ~/git/marcel$ x = (123)
M 0.18.3 jao@loon ~/git/marcel$ (x)

Environment variables can store structured types too. For example, you can assign a list to a variable:

M 0.18.3 jao@loon ~/git/marcel$ x = ([1, 'two', 6 / 2])
M 0.18.3 jao@loon ~/git/marcel$ (x)
[1, 'two', 3.0]

[1, 'two', 6 / 2] is a list, and by enclosing this expression in parentheses, the value of the list can be assigned to the variable x.

Some Python types, like lists, can be modified, and this can be done through marcel. For example, to append to x's list:

M 0.18.3 jao@loon ~/git/marcel$ (x.append(4))
M 0.18.3 jao@loon ~/git/marcel$ (x)
[1, 'two', 3.0, 4]

Finally, environment variables can be deleted:

M 0.18.3 jao@loon ~/git/marcel$ env -d x
('x', [1, 'two', 3.0, 4])
M 0.18.3 jao@loon ~/git/marcel$ (x)
Error: Running map(lambda: x): name 'x' is not defined

bottom of page