How to implement factory patterns or other solutions more elegantly

The

scenario is that
has a stack of py files in the commands directory. Each file is a class. Each class has a different approach.

such as

-sharp daemon.py 
import commands

while True:
    message = json.loads(mq.receive())
    if not hasattr(commands, message["class"])
        logger.warn("error")
    command = commands[message["class"]]()
    command. message["action"] (message) ????

how should it be implemented or I shouldn"t use python? in this way Are you used to using php?

May.09,2021

answer your own questions.

module = __import__('module.%s' % modulename)
class_ = module()
func = getattr(class_, 'func')
func()
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b362f0-2c000.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b362f0-2c000.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?