简体   繁体   English

TypeError(“模块”对象不可调用)

[英]TypeError ( 'module' object is not callable )

I have two Scripts.我有两个脚本。 Script 1 is titled schemeDetails .The second script is a test script called temporaryFile that creates a schemeSetup object using the schemeSetup class which is within schemeDetails.脚本 1 的标题是schemeDetails 。第二个脚本是一个名为temporaryFile的测试脚本,它使用schemeDetails 中的schemeSetup 类创建一个schemeSetup 对象。 Everything is hunky dory up to the point where I try to acess the method insertScheme which is within the schemeSetup Class.直到我尝试访问 schemeSetup 类中的方法 insertScheme 为止,一切都是笨拙的。

I have imported the schemeDetails script using the following:我已经使用以下命令导入了 schemeDetails 脚本:

import schemeDetails
reload(schemeDetails)
from schemeDetails import *

I can create the schemeDetails Object and access its attributes我可以创建 schemeDetails 对象并访问它的属性

d = schemeDetails.schemeSetup() -- fine
print(d.scheme) -- fine
d.insertScheme() -- throws error

but trying to call the insertScheme function throws an error但尝试调用 insertScheme 函数会引发错误

I don't know why this is happening as the import statement looks above board to me.我不知道为什么会发生这种情况,因为 import 语句在我看来是光明正大的。 Any advice appreciated任何建议表示赞赏

from sikuli import *
import os

class schemeSetup(object):
    #Uses default values
    def __init__(
        self,
        scheme = "GM",
        cardNumber = "1234567A",
        month = "December",
        year = "2015",
        setSchemeAsDefault = True):

        #Provide default values for parameters
        self.scheme = scheme
        self.cardNumber = cardNumber
        self.month = month
        self.year = year
        self.setSchemeAsDefault = setSchemeAsDefault
        #schemeDetails is not a sub
        # class of patient. It is simply defined within the patient class 
        # - there is a huge difference. 

#====================================================#        
        #schemeDetails Function
    def insertScheme(self):
        print("insertScheme Works")    
        #r = Regions()
        #r.description("Patient Maintenance", "schemeDetails")
        #myRegion = r.createRegion()
        #myRegion.highlight(1)  

        #click(myRegion.find(insertSchemeButton))
        #click(myRegion.find(blankSchemeEntry))
        #type(self.scheme + Key.ENTER + Key.ENTER)           
        #type(self.cardNumber + Key.ENTER)
        #type(self.month + Key.ENTER)
        #type(self.year + Key.ENTER)
        #type(" ")
        #unticks HT link, HT linking should be in a separate function

#====================================================#           
        #schemeDetails Function
    def editScheme(self):
        print("editScheme Works")

#====================================================#        
    def deleteScheme(self):
        pass
#====================================================#  

It may be of importance that calling either of the bottom functions does not produce an error.调用任何一个底部函数都不会产生错误可能很重要。 If I put print("Hello") under editScheme, and call that method using s.editScheme the program compiles but I get no output.如果我将 print("Hello") 放在 editScheme 下,并使用 s.editScheme 调用该方法,程序编译但我没有得到任何输出。 If I run print(s.editScheme) it returns None如果我运行 print(s.editScheme) 它返回 None

Well it seems to be fixed now after changing the import format to this好吧,在将导入格式更改为此之后,它现在似乎已修复

    import schemeDetails 
    from schemeDetails import schemeSetup
    s = schemeDetails.schemeSetup()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM