Skip to content

sys

The process this program is running as: its arguments, its name, and its environment.

import sys

args

def args() -> [String]

The arguments the program was started with, not counting the program’s own name: the words after -- in pyk program.pyk -- a b.

Returns

The arguments, in order; an empty list when there are none.

Example

env

def env() -> [(String, String)]

Every environment variable the program was started with.

Returns

A list of (name, value) pairs, in no particular order.

Example

env_get

def env_get(name: String) -> String

The value of the environment variable name.

Parameters

  • name: the variable, such as "HOME".

Returns

Its value, or "" when it is not set. A variable set to "" answers the same, and env_has tells the two apart.

Example

env_has

def env_has(name: String) -> Bool

Tells whether the environment variable name is set, even to "".

Parameters

  • name: the variable, such as "HOME".

Returns

true when it is set, false otherwise.

Example

exit

def exit(code: Int) -> ()

Ends the program at once with exit status code. Output written so far is written out first, and nothing after the call runs. A program that never calls it ends with status 0.

Parameters

  • code: the exit status; 0 means success, anything else failure.

Example

prog_name

def prog_name() -> String

The name the program was started as, without its directory, such as hello.pyk or hello.

Returns

The name; "" where the host does not know one, as in a browser.

Example

prog_path

def prog_path() -> String

The directory the program was started from.

Returns

The directory as an absolute path; "" where the host does not know one, as in a browser.

Example