2014-07-10 45 views
1

我預計inspect模塊默認集成到wsadmin中,因爲它是jython 2.1的一部分,它是wsadmin似乎正在使用的jython版本(2,1,0,'final ',0)根據sys.version_info。我得到這個錯誤「ImportError:no module named inspect」在wsadmin中模擬Python的inspect模塊的功能

我想使用inspect.isfunction()和inspect.getargspec()來允許更高級別的perl腳本檢查命令的用法是否正確,並調用按名稱任意wsadmin jython函數。

有沒有什麼辦法可以模仿這些功能而無需檢查? 另外,爲什麼檢查失蹤?現在看來似乎應該是有...

回答

0

這將效仿inspect.isfunction():

import types; 
isinstance(obj, types.FunctionType) 

這將效仿inspect.getargspec()(我的目的至少)

# Gets list of arguments of function myFx 
myFx.func_code.co_varnames[:myFx.func_code.co_argcount] 

# Gets a list of the default values of myFx arguments 
myFx.func_defaults