是否有适用于Python的AOP支持库?
我正在尝试在Python编程中使用一些AOP,但是我对现有的各种库没有任何经验.
I am trying to use some AOP in my Python programming, but I do not have any experience of the various libraries that exist.
所以我的问题是:
Python有哪些AOP支持?两者之间的差异库有什么优势?
What AOP support exists for Python? And what are the advantages of the differents libraries between them?
编辑
我找到了一些,但我不知道它们的比较:
Edit
I've found some, but I don't know how they compare:
- Aspyct
- Lightweight AOP for Python
我将在哪种情况下使用它们?
In which context will I use these?
我有两个用Python编写的应用程序,它们通常具有计算税金和其他金钱事物的方法.我希望能够编写功能的骨架",并在运行时对其进行自定义,例如,更改地方税的应用方式(按国家/地区,州或城市等),而不必超载全栈.
I have two applications, written in Python, which have typically methods which compute taxes and other money things. I'd like to be able to write a "skeleton" of a functionality, and customize it at runtime, for example changing the way local taxes are applied (by country, or state, or city, etc.) without having to overload the full stack.
我不再维护pytilities,并且多年来一直未对其进行维护.您可能需要考虑其他答案之一,或者是Wikipedia上的
I no longer maintain pytilities and it has been unmaintained for years. You may want to consider one of the other answers instead or this list on Wikipedia.
另一个适用于python的AOP库为 pytilities
( svn回购).据我所知,它是目前功能最强大的.
Another AOP library for python would be pytilities
(Documentation; svn repo). It is currently the most powerful (as far as I know).
它的功能是:
- 制作可重用的Aspect类
- 将多个方面应用于实例或类
- 取消将方面应用于实例/类
- 使用方面将新属性添加到实例
- 将建议应用于实例/类的所有属性
- ...
它还具有其他优点,例如一些特殊的描述符(请参阅文档)
It also has other goodies such as some special descriptors (see the documentation)