【问题标题】:AttributeError: 'module' object has no attribute 'get_combos' [closed]AttributeError:“模块”对象没有属性“get_combos”[关闭]
【发布时间】:2012-09-17 06:07:40
【问题描述】:

大家好, 这是我在运行 python 文件时遇到的问题

execfile("create_revdict.py")

我明白了

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "create_revdict.py", line 91, in <module>
    combos =  QuickSky.get_combos(det_keys)
AttributeError: 'module' object has no attribute 'get_combos'

但是当我查看 QuickSky 模块时,它是从 pyc 文件导入的 我找到了

help(QuickSky)


FILE
    /Users/alessandromanzotti/Downloads/FindSkyArea/QuickSky.pyc

CLASSES
__builtin__.object
    Mapper

class Mapper(__builtin__.object)
 |  This is a Mapper class to map the timedelays to the 
 |  keys
 |  
 |  Methods defined here:
 |  
 |  __init__(self, dets, timescope=10000)
 |  
 |  convert_bin_time(self, bin)
 |  
 |  convert_time_bin(self, t)
 |  
 |  create_combo_error(self, error_dict)
 |  
 |  create_dict(self, grid_size, func_time_dict, *args)
 |      Create the actual reverse dictionary
 |      @param grid_size: grid size in radians
 |      @param func_time_dict: function to return the time dict 
 |                            for a given sky position. 
 |                            fun(lon, lat)
 |  
 |  create_key(self, timedelay_dict)
 |      Create a key from the time delay dict
 |  
 |  create_key_list(self, timedelay_dict, error_dict)
 |      Create a bunch of keys including the errors
 |      @params timedelay_dict: timedelay betwen the different sites
 |      @params error_dict: the individual detector timing errors
 |  
 |  create_key_list_ellipse(self, timedelay_dict, error_dict)
 |  
 |  get_combos(self)
 |      Create all possible combinations from the det_keys list, 
 |      in alphabetical order
 |  
 |  get_point_area_sqd(self)
    get_points(self, listkeys)
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
 FUNCTIONS
 define_network(det_keys, flow=10.0)
    Creates the detector network to use
    @param det_keys: list of detectors to be included in the network
    @param flow: The lower cutoff frequency [Hz]

看来 QuickSky 有一个属性 get_combos。

很遗憾,我没有编写 QuickSky.pyc,因此我无法访问 QuickSky.py 源代码。

可能是什么错误?

【问题讨论】:

    标签: python methods module attributeerror


    【解决方案1】:

    正如消息告诉您的,get_combos 不是模块QuickSky 的函数。您可以通过dir(QuickSky)查看该模块的内容。

    看起来get_combosQuickSky.Mapper 类的方法。您可能需要使用适当的 dets 参数创建后者的实例。

    【讨论】:

      猜你喜欢
      • 2023-03-22
      • 2012-06-02
      • 2015-03-21
      • 2010-11-18
      相关资源
      最近更新 更多