The os module
What the operating system provides beyond the running process: environment variables, clocks and time, and the machine and user.
os is a module: bring it in with import os (and write
os.environment("HOME")) or import names directly with
import [Instant, Duration] from os.
- Environment:
environment(name),environment_variables(),set_environment(name, value)andremove_environment(name) - Time:
Duration,Instant(a monotonic clock, for measuring) andSystemTime(the wall clock) - Machine:
system_os(),system_name(),system_version(),architecture(),hostname(), processor counts,total_memory(),page_size() - User:
user_name(),home_directory(),temp_directory(),is_elevated()
Example
import os;
main(): int {
var start = os.Instant.now();
var runtime = os.environment("PEPPER_RUNTIME").value_or("runtime");
print($"runtime at {runtime} on {os.hostname()}");
print($"took {os.Instant.now() - start}");
return 0;
}
Source: runtime/os/module.pep