Python Forum
Is there a better data structure than classes for a set of employes?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a better data structure than classes for a set of employes?
#3
Example with dictionaries:
employeList = {
    {
       "name": "susan",
       "nationality": "netherland",
       "overallCost": None
    },
    ...
}

# resolve overall cost for susan
employeList[0]["overallCost"] = resolveOverallCost(employeList[0])

workWithEmployeList()
Example with yaml:
# employe.yml
- name: susan
  nationality: netherland
...

# python script

class employeObject:
    overallCost = None
    def __init__(self, name, nationality):
        self.name = name
        self.nationarlity = nationality
        self.resolveOverallCost()

    def resolveOverallCost(self):
        ...
        self.overallCost = calculatedValue

open(yamlfile):
    employeList = readYamlFile()

for employe in employeList:
    emloyeObjectList.append(employeObject(employe["name], emplaye["nationality"])

workWithEmployeObjectList()
Reply


Messages In This Thread
RE: Is there a better data structure than classes for a set of employes? - by Schlangenversteher - Feb-26-2020, 10:15 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Data structure question standenman 1 755 Jun-04-2023, 11:51 AM
Last Post: jefsummers
  Data saving structure JosefFilosopio 0 2,211 May-04-2019, 10:48 AM
Last Post: JosefFilosopio
  What data structure I need dervast 3 2,699 Apr-07-2019, 11:50 PM
Last Post: scidam
  Replacing values for specific columns in Panda data structure Padowan 1 14,772 Nov-27-2017, 08:21 PM
Last Post: Padowan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020