Method: RubyPython.import

Defined in:
lib/rubypython.rb

.import(mod_name) ⇒ RubyPyModule

Import a Python module into the interpreter and return a proxy object for it. This is the preferred way to gain access to Python object. module

Parameters:

  • mod_name (String)

    the name of the module to import

Returns:



109
110
111
112
113
114
115
116
# File 'lib/rubypython.rb', line 109

def import(mod_name)
  pModule = Python.PyImport_ImportModule mod_name
  if(PythonError.error?)
    raise PythonError.handle_error
  end
  pymod = PyObject.new pModule
  RubyPyModule.new(pymod)
end