Separate roles into modular parts that are interdependent I have a IRC bot that I'm writing (code is here, bot24-irc.py is the main module).

This bot needs to be able to perform many different, separate roles so that each can be reloaded and sandboxed (for stability). I'm defining a role as being a function that reads all PRIVMSGs sent and returns a list of responses. At this moment, each role is in a separate module (just one right now, phablookup.py). I'm using the class role as a sort of wrapper to create a uniform way to "talk" to each module, to translate what the role modules want (a (different) function called with the right (different) arguments) to what the main module wants (a list of responses).

Here is the role class:

class role:
    run = False
    moduleName = ""
    checkFunc = ""
    args = []

    def init(self):
        if self.moduleName:
            try:
                print("Importing: " + self.moduleName)
                self.module = __import__(self.moduleName)
            except SyntaxError:
                print("Syntax error with " + self.moduleName + ", skipping...")
                self.run = False
                return 1
            except ImportError:
                print("Could not find " + self.moduleName + ", skipping...")
                self.run = False
                return 1
            else:
                self.funcToCall = getattr(self.module, self.checkFunc)
                return 0
        else:
            return 0

    def stop(self):
        self.run = False

    def start(self):
        self.run = True

    def check(self):
        if self.run:
            if self.moduleName:
                results = self.funcToCall(*self.args)
            else:
                results = self.checkFunc(*self.args)
            return results
        else:
            return ""

    def reload(self):
        if self.moduleName:
            try:
                reload(self.module)
            except SyntaxError:
                print("Syntax error with " + self.moduleName + ", skipping...")
                self.run = False
                return 1
            except ImportError:
                print("Could not find " + self.moduleName + ", skipping...")
                self.run = False
                return 1
            else:
                return 0
        else:
            return 0


And this is how I specify a new role:

phabLookup = role()
roles.append(phabLookup)
phabLookup.run = True
phabLookup.moduleName = 'phablookup'
phabLookup.checkFunc = 'lookup'
phabLookup.args = [msg, config['phabricator']['site'], config['phabricator']['apitoken']]


Now what I'm asking is this: is this type of module-per-role idea a good way to separate roles? Does it conform to best practices? It feels like its over complicating a really easy task. What is a better way to separate roles?
In Python 2.x, when creating classes, you need to explicitly have them inherit from object, like this: class MyClass(object):. If you're using Python 3.x, then you can write them like this: class MyClass:

Secondly, the general style for naming in Python is snake_case for functions and variables, and PascalCase for classes. If you have a constant variable, then it should be in UPPER_SNAKE_CASE.

The following line of code in your role.reload function can simply be changed to return 0:

else:
    return 0


This also applies to your role.check function. else: return "" can be changed to return "".

Also, I noticed that you're returning either 1 or 0 in your role.reload function. Do you mean to be returning True or False? This also applies to your role.init function as well.

Finally, in your role.check function, the below block of code can be changed to this: return self.funcToCall(*self.args) if self.moduleName else self.checkFunc(*self.args).

if self.moduleName:
    results = self.funcToCall(*self.args)
else:
    results = self.checkFunc(*self.args)
return results