#include "python.h" namespace python { Module & Module::operator=(PyObject * obj) { DEBUG("Module & Module::operator=(PyObject * " << obj << ")"); if (ptr() != obj) { set(obj); } return *this; } Module & Module::operator=(const Object & obj) { DEBUG("Module & Module::operator=(const Object & " << obj << ")"); return (*this = *obj); } void Module::reload() { set( PyImport_ReloadModule( ptr() ) ); decref(); } bool Module::accepts(PyObject * obj) const { return ( obj != NULL ) ;//and PyModule_Check( obj ); } Dict Module::get_dict() { return Dict ( PyModule_GetDict( ptr() ) ) ; } Object Module::run_method(string method_name,string argfmt,...) { DEBUG("Object Module::run_method(string \""<( argfmt.c_str() ),argslist); Object retval = PyEval_CallObject(*method,*args); return retval; } Object Module::run_method(string method_name,Tuple & args) { Object method = get_attr(method_name); if ( not method.is_callable() ) { throw Exception(method_name + " in " + this->as_string() + "is not callable"); } return Object ( PyObject_CallObject(*method,*args) ); } }