src/pylib/Lib/sys

Source   Edit  

Lib/sys

Hint: if not defined pylibConfigIsolated, this module will call setlocale(LC_CTYPE, ""), a.k.a. changing locale to user's configure, just as CPython's initialization.

Vars

orig_argv = newPyListOfCap(argc)
Source   Edit  
stderr = newNoEncTextIO(stderr, "<stderr>", DefNewLine)
Source   Edit  
stdin = newNoEncTextIO(stdin, "<stdin>", DefNewLine)
Source   Edit  
stdout = newNoEncTextIO(stdout, "<stdout>", DefNewLine)
Source   Edit  

Lets

dunder_stderr = stderr
__stderr__ Source   Edit  
dunder_stdin = stdin
__stdin__ Source   Edit  
dunder_stdout = stdout
__stdout__ Source   Edit  

Consts

byteorder = "little"
Source   Edit  
float_info = (max: 1.7976931348623157e+308, max_exp: 1024, max_10_exp: 308,
              min: 2.2250738585072014e-308, min_exp: -1021, min_10_exp: -307,
              dig: 15, mant_dig: 53, epsilon: 2.220446049250313e-16, radix: 2)
float_info.rounds is defined as a getter, see rounds Source   Edit  
hexversion = 201472
Source   Edit  
implementation = ("pynim", (0, 9, 3, "alpha", 0), 2307, false)
Source   Edit  
maxsize = 9223372036854775807'i64
Source   Edit  
platform: PyStr = "linux"
Note: the value is standalone for bare system

and haiku/netbsd appended with major version instead of "unknown". In short, this won't be "unknown" as Python does.

Source   Edit  
version = "3.13.0"
Source   Edit  
version_info = (major: 3, minor: 13, patch: 0, releaselevel: "final", serial: 0)
Source   Edit  

Procs

func exit(c: int) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc exit(s: PyStr) {....raises: [], tags: [], forbids: [].}
Source   Edit  
func exit(x: NoneType) {....raises: [], tags: [], forbids: [].}
Source   Edit  
func exit[T](obj: T)
Warning: this does not raise SystemExit, which differs Python's
Source   Edit  
proc getdefaultencoding(): PyStr {....raises: [], tags: [], forbids: [].}

Return the current default encoding used by the Unicode implementation.

Always "utf-8" in Nim

Source   Edit  
proc getfilesystemencoding(): PyStr {....raises: [], tags: [], forbids: [].}
Source   Edit  

Converters

converter noneStdstream(n: NoneType): typeof(stdout) {....raises: [], tags: [],
    forbids: [].}
Source   Edit  

Templates

template executable(): PyStr
returns:
  • when nimscript, path of Nim;
  • when JavaScript:
    • on browser: empty string
    • on NodeJS/Deno: executable path of Node/Deno
  • otherwise, it's the path of current app/exe.
Source   Edit  
template getsizeof(x): int
Source   Edit  
template getsizeof(x; default: int): int
may be used when sizeof(x) is a compile-error e.g. func sizeof(x: O): int{.error.} for O Source   Edit  
template rounds(fi: typeof(float_info)): int
not available when nimscript Source   Edit