UserLinux chooses Python as "interpretive language" of choice

John Roth newsgroups at jhrothjr.com
Sat Dec 20 12:53:10 EST 2003


"Oren Tirosh" <oren-py-l at hishome.net> wrote in message
news:mailman.376.1071937470.9307.python-list at python.org...
> On Sat, Dec 20, 2003 at 08:44:45AM -0500, John Roth wrote:
> > I'm not certain I'm making the connection. The visitor pattern
> > as I use it doesn't seem to have much to do with generators.
> > It's a way of disconnecting the sequencing logic from the
> > processing logic,
>
> You mean like this?
>
>   def generator(...):
>      sequencing logic, yield stuff
>
>   for object in generator(...):
>      processing logic

Good point. That's upside down from the way I usually
think of it.
>
> > while a generator seems to encapsulate both in the same function.
>
> Can you give any specific reasons why you believe this to be the
> case?

Yes. You now have two sequencing constructs: the for loop
and the loop inside the generator. The visitor pattern has only
one: the for loop inside the .visit() method.

John Roth


>
>    Oren
>






More information about the Python-list mailing list