mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
Update os.md
This commit is contained in:
parent
cd2de2c388
commit
5e55df9b97
@ -42,3 +42,19 @@ Check if the given path exists.
|
|||||||
### `os.path.basename(path: str)`
|
### `os.path.basename(path: str)`
|
||||||
|
|
||||||
Returns the basename of the given path.
|
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);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user