Is this..... evil?

Michal Wallace sabren at manifestation.com
Sat Feb 9 17:56:20 EST 2002


On 9 Feb 2002, Philip Swartzleonard wrote:

> class Reciever:
>     def message( self, message ):
>         methname = 'rec_' + message.type
>         if hasattr(self, methname):
>             if callable(getattr(self, methname)):
>                 getattr(self, methname)(message)

[snip]

> Anyway, i was just wondering, since this seems so great, is there 
> anything wrong with doing things this way that i'm not seeing?

I do the exact same thing with web apps. I have an "Actor"
class, which, when you pass it an "action" on the command
line, dispatches it to the approprirate act_xxxx() routine.
It's one of the cleanest ways I've seen to write web
applications.

Cheers,

- Michal   http://www.sabren.net/   sabren at manifestation.com 
------------------------------------------------------------
Give your ideas the perfect home: http://www.cornerhost.com/
 cvs - weblogs - php - linux shell - perl/python/cgi - java
------------------------------------------------------------





More information about the Python-list mailing list