Module: RbbtPython

Extended by:
PyCall::Import
Defined in:
lib/rbbt/util/python.rb

Class Method Summary collapse

Class Method Details

.run(mod = nil, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rbbt/util/python.rb', line 7

def self.run(mod = nil, &block)
  begin
    pyimport mod unless mod.nil?
    case block.arity
    when 0
      yield 
    when 1
      yield self.send(mod)
    else
      raise "Unknown arity on block of code #{block.arity}"
    end
  rescue
    Log.exception $!
  end
end