|
|
@@ -42,3 +42,19 @@ Check if the given path exists.
|
|
|
### `os.path.basename(path: str)`
|
|
|
|
|
|
Returns the basename of the given path.
|
|
|
+
|
|
|
+
|
|
|
+## Other functions
|
|
|
+
|
|
|
+You can add other functions to `os` module via normal binding if you need them.
|
|
|
+For example, add `os.system`:
|
|
|
+
|
|
|
+```cpp
|
|
|
+PyObject* mod = vm->_modules["os"];
|
|
|
+
|
|
|
+vm->bind(mod, "system(cmd: str) -> int", [](VM* vm, ArgsView args){
|
|
|
+ const char* cmd = py_cast<CString>(vm, args[0]);
|
|
|
+ int code = system(cmd);
|
|
|
+ return py_var(vm, code);
|
|
|
+});
|
|
|
+```
|