Python vs C for a mail server
aleax at mail.comcast.net
Mon Jan 30 00:53:30 CET 2006
Jay Parlar <jparlar at cogeco.ca> wrote:
> >> From Lib/compiler/visitor.py:
> > meth = getattr(self.visitor, 'visit' + className, 0)
> I even said you can do some "very powerful things" with getattr, by
> which I meant something exactly like you did. What did you think I
> meant by that?
getattr is very nice, but "Acyclic Visitor" (aka "Dynamic Visitor",
essentially the same design pattern) can be implemented in C++, and
indeed I believe it was first published by Robert Martin exactly for C++
(at PLOP3 in '97). Cfr
<http://www.objectmentor.com/resources/articles/visitor> for an updated
and wider treatment.
Python is handier, but, with more effort, you can get similar dynamic
effects in C++ (and with an intermediate amount of effort in Java),
which is part of what amuses me when I see Java or C++ people making
claims that Python's dynamic abilities must cause problems...;-).
More information about the Python-list