0

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
2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by eyewirejets
1

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.

Votes + Comments
Awesome
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.