Aspect Programming Module

Will Stuyvesant hwlgw at hotmail.com
Fri Apr 16 08:42:50 EDT 2004


I apologize for the earlier post, written in a bad mood.

I recently had to listen to a scientific talk about AOP and I did 
not like the talk...

It seems to me there are *numerous* ways to do AOP in Python.

Years ago (1997?) GvR mentioned using __getattr__() to trap method
calls, and since then also metaclasses have been added to do things
like adding logging capabilities.

A thread from 2003 with Alex Martelli: http://tinyurl.com/2o267
is even specifically about logging.

I am not an expert on this style of programming.  Perhaps you are
right that an aop or mixin or ... module could be useful in Python.
Show use cases?  For example:

The following code:

    class MyLogger:
        def log(self): pass
    class MyClass: pass

    addMe(MyClass, MyLogger.log)

would result in MyLogger.log being called after each call to a
method of MyClass?   And then you need others that add things
*before* method calls.  Etc. etc.  What are good usage examples?

underscore-programming-indicates-early-design-errors-ly y'rs  - will



More information about the Python-list mailing list