SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2014
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Python Class Creation Confusion Craziness

    My program is suppose to create a class named Empoyee that holds the following data about an empoyee in attributes: name, id number, department, & job title. Second, create 3 objects to hold specified data. Finally, the program should store/display the specified data in the 3 objects.

    I am receiving the following Traceback error:

    TypeError: 'str' object is not callable

    I provided an attached .txt file with the whole code, but the following is where the error is occurring:

    class Employee:
    def __init__(self, name, idNumber, department, jobTitle):
    self.name = name
    self.idNumber = idNumber
    self.department = department
    self.jobTitle = jobTitle
    def employee_1_information(self, name, idNumber, department, jobTitle):
    self.name = name
    self.idNumber = idNumber
    self.department = department
    self.jobTitle = jobTitle
    return self.name, self.idNumber, self.department, self.jobTitle
    def employee_2_information(self, name, idNumber, department, jobTitle):
    self.name = name
    self.idNumber = idNumber
    self.department = department
    self.jobTitle = jobTitle
    return self.name, self.idNumber, self.department, self.jobTitle
    def employee_3_information(self, name, idNumber, department, jobTitle):
    self.name = name
    self.idNumber = idNumber
    self.department = department
    self.jobTitle = jobTitle
    return self.name, self.idNumber, self.department, self.jobTitle

    def main():
    name = "Susan Meyers"
    idNumber = "47899"
    department = "Accounting"
    jobTitle = "Vice President"
    employeeData1 = Employee(name, idNumber, department, jobTitle)
    employeeData1.name(name)
    employeeData1.idNumber(idNumber)
    employeeData1.department(department)
    employeeData1.jobTitle(jobTitle)
    Attached Files Attached Files

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,313
    Mentioned
    19 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by point_maker View Post
    employeeData1.name(name)
    The name attribute is a string, not a function, so you can't invoke it as if it were a function.
    "First make it work. Then make it better."


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •