OO approach to decision sequence?

Magnus Lycka lycka at carmen.se
Tue Jun 21 07:41:45 EDT 2005


Chinook wrote:
> I understand what you are saying.  The point I'm messing up my head with 
> though, is when the entity (tree node in my case or variable record content 
> deconstructing in the aspect example I noted) is not an instance of a class 
> already - it is obtained from an external source and only decipherable by its 
> content.  

There are several aspects and approaches here, depending on
the data. If you receive a stream of text, you might want to
build a parser to handle that. For instance you might want
to use something like PyParsing. That's not really an OO
approach, but once you have your objects, it's time for OO! :)

Note, that while the basic approach of the factory patterns is
applicable to Python, most texts describe how to use it with
C++ or Java, and do a large degree, they are complicated by
shortcomings in those languages (such as static typing and
reliance on inheritence for polymorphism) that are non-issues
in Python. IOW, keep it simple.



More information about the Python-list mailing list