def test_hello(self): parent_dir = os.path.dirname( os.path.normpath(os.path.dirname(__file__))) sys.path.append(parent_dir + '/lib-python') lib_dir = os.path.join(parent_dir, 'lib-python') sys.path.append(lib_dir) print 'sys.path: ', sys.path print 'lib_dir: ', lib_dir print 'os.environ[PYTHONPATH]: ', os.environ['PYTHONPATH'] import hello print hello.__doc__ print hello.foo.__doc__ hello.foo(4)
import hello hello.foo(2)
import hello print '__doc__' print hello.__doc__ print 'foo.__doc__' print hello.foo.__doc__ print 'run' hello.foo(4)
import hello print(hello.foo(4))
from numpy import f2py source = ''' subroutine foo print*, "Hello world!" end ''' f2py.compile(source, modulename='hello') import hello hello.foo()
import hello val=51 hello.foo(val) array=[1,2,3,4,5,6,7,8,9,10] hello.foovec(array)