NameError: name 'BillPayer' is not defined

NameError: name 'BillPayer' is not defined

我在尝试运行我的代码时遇到上述错误。我认为这是一个广泛的错误,因为我所有的谷歌搜索都没有给我带来任何与我的实际情况相关的信息。我组织的目录是这样的:

Project (BillPay)
    bill.py (contains Class Bill())
    billPayer.py (contains Class BillPayer())
    main.py
    __init__.py

我把 __init__.py 留空了,据我所知没问题。

在main.py中,我有:

#!/usr/bin/python

import sys
sys.path.insert(0, "/home/matt/Documents/Code/BillPay")
import bill
import billPayer

bill_machine = BillPayer()
bill_machine.addBill(Google, 12345, 100.00, www.google.com)
bill_machine.printBills()

如果我导入了模块 billPayer(其中包含 BillPayer 类),那么我应该能够创建该类的实例,对吗?我错过了什么?

两种解决方法

billPayer.BillPayer()

from billPayer import BillPayer

bill_machine = billPayer.BillPayer()