Search code examples
pythonaop

Any AOP support library for Python?


I am trying to use some AOP in my Python programming, but I do not have any experience of the various libraries that exist.

So my question are:

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:

Edit 2

In which context will I use these?

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.


Solution

  • Edit: 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.

    Another AOP library for python would be pytilities (Documentation; svn repo). It is currently the most powerful (as far as I know).

    Its features are:

    • make reusable Aspect classes
    • apply multiple aspects to an instance or class
    • unapply aspects to an instance/class
    • add new attributes to an instance by using an aspect
    • apply advice to all attributes of an instance/class
    • ...

    It also has other goodies such as some special descriptors (see the documentation)