os Module
The os module provides system diagnostics, platform detection, hardware resources (CPU/RAM), and user environment paths.
Importing
djazair
use os
API Reference
| Function | Description |
|---|---|
os.platform() | Returns platform name ("windows", "linux", "macos"). |
os.isWindows() / isLinux() / isMac() | Boolean platform checks. |
os.cpuCount() | Number of logical CPU cores available. |
os.totalMemory() / freeMemory() | Total and available physical system RAM in bytes. |
os.hostname() | Returns network machine hostname. |
os.username() | Current logged-in system user. |
os.homeDir() | User home directory path. |
os.tmpDir() | System temporary directory path. |
os.which(binaryName) | Resolves executable path in system PATH (or Null). |
Example Usage
djazair
use os
print("OS Platform: ${os.platform()}")
print("CPU Cores: ${os.cpuCount()}")
print("Total Memory: ${os.totalMemory() / (1024 * 1024 * 1024)} GB")
print("Temp Dir: ${os.tmpDir()}")