code: def get_commands(mod):
      
      import inspect
      import types
  
      commands = {}
  
      def check(c):
          return (inspect.isclass(c) and
              issubclass(c, Command) and c is not Command and not issubclass(c, CommandManager))
  
      for name in dir(mod):
          c = getattr(mod, name)
          if check(c):
              commands[c.name] = c
  
      return commands
docs: Find commands from a module