im learning to make an organizational chart using class
class employee:
def __init__(self, name , title, salary):
self.name = name
self.title = title
self.salary = salary
abcde = employee("Elon Musk", "CEO",1000000)
print(employee.self) --> error
Basically what im trying to do is to get the "abcde" value, to use it on my other function..
is there anyway to get the name assigned to the object? in this case "abcde"
Recreating this post to clarify what im trying to do:
I simplified the complete code that i have here, but basically what im trying to do here is getting the assigned class name, in this case "abcde".
i understand that self.name will get me "elon musk: self.title will get me "CEO"
but how do i get the "abcde"?
why do i need the abcde? because i need to append the abcde to a list called
direct_report_list= []
to append the "abcde" inside this list, which i will use for this:
def __str__(self):
otheremp_list = []
print(self.title,” – “, self.name)
print(“Direct Reports:”)
for emp in self.direct_reports_list:
print(emp.title,” – “,emp.name)
otheremp_list.append(emp.direct_reports_list)*
print(“other employees:”)
for emp in otheremp_list:
print(emp.title,” – “,emp.name)
otheremp_list.append(emp.direct_reports_list)*
i need the "abcde" value so i can add this value into my list, which i use for the "emp" in str