In need of a binge-and-purge idiom

Jeremy Fincher tweedgeezer at hotmail.com
Tue Mar 25 02:26:54 EST 2003


mlh at furu.idi.ntnu.no (Magnus Lie Hetland) wrote in message news:<slrnb7v8ai.bop.mlh at furu.idi.ntnu.no>...
> You should add "if acc" before you yield acc -- I don't want an empty
> acc (that only means several separators in a row -- which amounts to a
> single separator in my case).

That makes sense.  To be truly general, that should be a named
argument with a default to not return empty values.


> And, with that statement in place, you'd
> get the same duplication as before, as far as I can see. What is new
> about this (except putting it inside a generator)?

Simply that once writing it, the ugliness is contained in that one
function, and all your code that needs the behavior you describe can
be written much more beautifully :)

Jeremy




More information about the Python-list mailing list