Geir Arne Hjelle - Plugins: Adding Flexibility to Your Apps - PyCon 2019

preview_player
Показать описание
"Speaker: Geir Arne Hjelle

Python is a flexible language. Your Python app, on the other hand, is usually more set in stone: buttons, functions, displays are all explicitly defined.

In this talk you'll learn how to take advantage of features like decorators and functions as first-class objects to set up a simple plugin system that allows your app to be more flexible. In fact, you can allow your users to add or customize functionality they want after you ship.

By using plugins, your code becomes more modular and maintainable. At the same time your users may be able to use your great app to work with data or challenges you didn't even know existed.

Рекомендации по теме
Комментарии
Автор

apologies for the following comments (and this is just my opinion of course) but a couple thoughts: it would have been more interesting if the presenter talked about ‘pyplugs’ since that’s where the so-called ‘plugin system’ implementation is at.. but even then.. this package, ‘pyplugs’, is rather useless given the awesome functionality bundled with python3, and if you choose to use it ..well.. you’re just adding an unnecessary dependency and prbly much more overhead than required ... and the title of this talk.. misleading. what is shown here is basically the ‘registry pattern’ — a textbook example used in nearly all of the 1 billion decorator tutorial articles you find online. ie, a 30min talk for a 3min read. also to me, this isn’t an effective plugin system. a plugin system, and again this is just my opinion, allows your users to extend the core library/tool functionality ..with the stuff shown in this talk, there’s way too many steps for an outsider to ‘plugin’. it’s even alluded to in the questions. what we have here is more akin to parametric polymorphism (sorry if i got the terminology mixed up) and a demonstration of elementary oop concepts. anyway if that’s what you want and you want to do what this guy is doing, it‘s simpler to take advantage of abstract base classes and then use ‘__init_subclass__’ to do the registration. way easier. but hey if the bar is this low to do a talk at pycon, sign me up. i’d gladly do a talk on an actual plugin system. once more, apologies if my comments are harsh.

mishasawangwan