I have wriiten the Simple class .py file which has the class class Employee:
empCount = 0
def __init__(self, name, salary):
self.name = name
self.salary = salary
Employee.empCount += 1
def displayCount(self,salary):
print "Total Employee %d" % Employee.empCount
def displayEmployee(self):
print "Name : ", self.name, ", Salary: ", self.salary
and now i have written the another script to import the file and get the methods in the class but i am not able to fetch the methods
import inspect
import sys
pat="E://pythonscripts"
sys.path.append(pat)
#pat="E:/pythonscripts/Simpleclass"
__import__('Simpleclass', globals={})
for name, method in inspect.getmembers('Simpleclass', inspect.ismethod):
print name
(args, varargs, varkw, defaults) = inspect.getargspec(method)
for arg in args:
print arg
when running the inspect script i am getting the following error
Traceback (most recent call last):
File "C:/Python27/stack.py", line 9, in <module>
for name, method in inspect.getmembers(Employee, inspect.ismethod):
NameError: name 'Employee' is not defined