Visitor design pattern for python objects?
Magnus L. Hetland
mlh at vier.idi.ntnu.no
Wed Nov 24 02:50:10 CET 1999
Nicky <nickysandhu at hotmail.com> writes:
> Is there a visitor type method that exists for all python objects?
> Visitor methods would be useful to allow an apply type functionality
> for objects.
> base python object has accept method
> def accept(this,visitor):
> The visitor than would be called back with the particular type of
> object allowing the python object to delegate behavior to the visitor
> object. Is this already implemented or is there an alternative way of
> doing this?
Wouldn't every subclass have its own accept-method to avoid using the
superclass in the visit-method? (Maybe I have missed some
coercion-rules here...) In that case, each accept-method may have a
visit-method name of a different name, at least... (visitSimpleNode
Magnus Echelon jamming noise:
Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism
Hetland Special Forces Delta Force AK47 Hillary Clinton
More information about the Python-list