How do you call a method from the main() from a module to print base class attributes. Objects are contained in a list.

Module

def show_employee(self):
        print 'Employee Name: ', self.__employee_name
        print 'Employee Number: ', self.__employee_number

Recommended Answers

All 2 Replies

I'm highly confused... so what are you asking to call? Assuming you have the attributes __employee_name and __employee_number on the class this function is a part of, this should run fine...
So I'm going to assume that the objects in this list you mentioned are instances of this class, in which case you could cycle through it and just call this function from each one, like this:

for instance in myList:
    instance.show_employee()

Hopefully this is what you wanted; just tell me if I was way off from your question or something.

commented: Awesome +1

Thanks for the help. Got it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.