【问题标题】:Emulating functionality of python's inspect module in wsadmin在 wsadmin 中模拟 python 的检查模块的功能
【发布时间】:2014-07-10 20:12:10
【问题描述】:

我希望 inspect 模块默认集成到 wsadmin 中,因为它是 jython 2.1 的一部分,根据 sys.js,wsadmin 似乎使用的是 jython 版本 (2, 1, 0, 'final', 0)。版本信息。我收到此错误“ImportError:没有名为检查的模块”

我正在尝试使用 inspect.isfunction() 和 inspect.getargspec() 来允许更高级别的 perl 脚本检查命令使用是否正确,并按名称调用任意 wsadmin jython 函数。

有没有什么方法可以在不检查的情况下模拟这些函数的行为? 另外,为什么检查缺失?好像应该有……

【问题讨论】:

    标签: python websphere jython wsadmin


    【解决方案1】:

    这将模拟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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-16
      • 2018-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-28
      • 1970-01-01
      相关资源
      最近更新 更多