FAQ

On Sun, 23 Mar 2003 14:19:53 -0500, "Tim Peters" wrote:

If the code made sense <wink>, something like

def terminated_iterator(iterable, a_seperator):
for element in iterable:
yield element
yield a_separator

would produce the original sequence, then tack a_separator on to the end.
Isn't it a general rule that terminators are easier to work with than
separators? I remember some programming guru saying this (Jon
Bentley?) I think it was Pascal's use of separators between
statements that convinced Dennis Ritchie to use terminators instead.

When I have to deal with separators, I always tack an extra one on the
end, using a trick like the one above, or a simple append or
concatenation. This is usually good to make a boolean or repeated
code vanish. For string processing, I usually throw an extra one on
the front too, for good luck.

Separator is also harder to spell than terminator. ;-)

Manuel

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 10 of 12 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedMar 23, '03 at 6:20p
activeMar 26, '03 at 6:14a
posts12
users7
websitepython.org

People

Translate

site design / logo © 2022 Grokbase