Implementing a Plugin System in Python

后端 未结 2 999
庸人自扰
庸人自扰 2021-02-15 12:14

I am writing an application (a server wrapper for Minecraft) that I wish to make extensible with plugins. I have a system in place that works, however I think that in the long r

2条回答
  •  暖寄归人
    2021-02-15 12:38

    Having written quite a few different plugin architectures in different platforms and languages, I will say that you are pretty much on track with how most plugins systems are written.

    Basically what it boils down to, is your host and your plugin need to have some kind of common contract to work with; in other words, your host needs to know enough about your plugin that it can pass along or share whatever common resources the plugin will need, and the plugin needs to know enough about the host to interact with those resources.

    Implementing this using a base class and a derived class as you have done is a very common methodology.

提交回复
热议问题