In need of a binge-and-purge idiom

Magnus Lie Hetland mlh at furu.idi.ntnu.no
Tue Mar 25 09:07:08 EST 2003


In article <698f09f8.0303242326.60c2f3b5 at posting.google.com>, Jeremy
Fincher wrote:
>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.
>

Maybe. I wasn't really looking for a general function/generator, but
for an idiom (i.e. a way of solving this with basic tools). An
unrealistic wish, perhaps :)

>
>> 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 :)

Indeed.

>Jeremy

-- 
Magnus Lie Hetland               "Nothing shocks me. I'm a scientist." 
http://hetland.org                                   -- Indiana Jones




More information about the Python-list mailing list