HeelToeHeroe
11-15-2010, 05:47 PM
Hello all,
first post here. I am a programming student learning python (I know some other languages pretty well) and I am baffled by this problem. I normally code in linux, but this program is for windows(don't see anything that makes this matter, but just in case).
I am trying to make an instance of the class Employee. When I try to do so, it says "Unbound Local Error: Local variable 'Employee' referenced before assignment". The thing is, I'm trying to create it, lol. I believe I have the right number of arguments for the __init__ function (self doesn't count when you create an instance, right?) so it shouldn't be looking for a different Employee class. Thanks for the help.
-HeelToe
import time
import os
global emps
def main():
startup()
loopit()
return
class Employee:
def __init__(self, ID, namef, namel):
self.PID =ID
self.fname = namef
self.lname = namel
self.timein = []
self.timeout = []
self.clockedin = 0
def show_wk_times():
print "showing week times for ", self.PID
def show_all_times():
print "showing all times for ", self.PID
def startup():
#os.system("cls")
global emps
emps = []
print "starting up!"
def loopit():
running = 1
global emps
#x = Employee(6912, 'Eric', 'Olsen')
emps.append(Employee(6912, "Eric", "Olsen"))
(code continues)
if __name__ == '__main__':
main()
first post here. I am a programming student learning python (I know some other languages pretty well) and I am baffled by this problem. I normally code in linux, but this program is for windows(don't see anything that makes this matter, but just in case).
I am trying to make an instance of the class Employee. When I try to do so, it says "Unbound Local Error: Local variable 'Employee' referenced before assignment". The thing is, I'm trying to create it, lol. I believe I have the right number of arguments for the __init__ function (self doesn't count when you create an instance, right?) so it shouldn't be looking for a different Employee class. Thanks for the help.
-HeelToe
import time
import os
global emps
def main():
startup()
loopit()
return
class Employee:
def __init__(self, ID, namef, namel):
self.PID =ID
self.fname = namef
self.lname = namel
self.timein = []
self.timeout = []
self.clockedin = 0
def show_wk_times():
print "showing week times for ", self.PID
def show_all_times():
print "showing all times for ", self.PID
def startup():
#os.system("cls")
global emps
emps = []
print "starting up!"
def loopit():
running = 1
global emps
#x = Employee(6912, 'Eric', 'Olsen')
emps.append(Employee(6912, "Eric", "Olsen"))
(code continues)
if __name__ == '__main__':
main()