Skip to content

Commit 4968edd

Browse files
committed
feat(typing): update the Python APIs exposed to JS
1 parent 8124f5a commit 4968edd

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

python/pythonmonkey/global.d.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,28 @@ declare const python: {
1111
};
1212
/** Python `print` */
1313
print(...values: any): void;
14-
/** Python `sys.stdout.write`. Write the given string to stdout. */
15-
stdout_write(s: string): void;
16-
/** Python `sys.stderr.write`. Write the given string to stderr. */
17-
stderr_write(s: string): void;
14+
/** Python `eval` */
15+
eval(code: string, globals?: Record<string, any>, locals?: Record<string, any>): any;
16+
/** Python `exec` */
17+
exec(code: string, globals?: Record<string, any>, locals?: Record<string, any>): void;
18+
/** Python `sys.stdout`. */
19+
stdout: {
20+
/** Write the given string to stdout. */
21+
write(s: string): number;
22+
read(n: number): string;
23+
};
24+
/** Python `sys.stderr`. */
25+
stderr: {
26+
/** Write the given string to stderr. */
27+
write(s: string): number;
28+
read(n: number): string;
29+
};
1830
/** Python `os.getenv`. Get an environment variable, return undefined if it doesn't exist. */
1931
getenv(key: string): string | undefined;
32+
/** Python `exit`. Exit the program. */
33+
exit(exitCode: number): never;
34+
/** Loads a python module using importlib, prefills it with an exports object and returns the module. */
35+
load(filename: string): object;
2036
/** Python `sys.path` */
2137
paths: string[];
2238
};

0 commit comments

Comments
 (0)