Method: RubyPython.run
- Defined in:
- lib/rubypython.rb
.run(options = {}, &block) ⇒ Object
Starts the Python interpreter (optionally with options) and executes the provided block in the RubyPython module scope. When the block exits for any reason, the Python interpreter is stopped automatically.
The last executed expression of the block is returned. Be careful that the last expression of the block does not return a RubyPyProxy object, because the proxy object will be invalidated when the interpreter is stopped.
- options
-
Configures the interpreter prior to starting it. Principally used to provide an alternative Python interpreter to start.
NOTE: In the current version of RubyPython, it is possible to change Python interpreters in a single Ruby process execution, but it is strongly discouraged as this may lead to segmentation faults. This feature is highly experimental and may be disabled in the future.
:call-seq: run(options = {}) { block to execute in RubyPython context }
216 217 218 219 220 221 |
# File 'lib/rubypython.rb', line 216 def run( = {}, &block) start() self.module_eval(&block) ensure stop end |