This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Redirecting embedded Python’s I/O | |
Posted on 2012-4-13 by mvasilkov | |
When using Python for application scripting, more often than not you want to redirect interpreter’s input/output to the embedding program. This is how it’s done with the Python/C API: | |
PyObject *sys = PyImport_ImportModule("sys"); | |
PyObject *out = PyFile_FromString("python_out", "w+"); | |
PyObject_SetAttrString(sys, "stdout", out); | |
Pretty intuitive, right? Now embedded Python’s stdout points to the newly created file, python_out. Working with the script’s output from C is also trivial: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# install rvm | |
aptitude install -y curl libz-dev | |
curl -L https://get.rvm.io | bash -s stable --ruby | |
source /usr/local/rvm/scripts/rvm | |
gem install fpm | |
# git clone | |
aptitude install -y git |