Jay Parlar <[EMAIL PROTECTED]> 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...;-). Alex -- http://mail.python.org/mailman/listinfo/python-list