Generator naming convention?

Georg Brandl g.brandl-nospam at gmx.net
Thu Jun 29 09:37:16 CEST 2006


aurora00 at gmail.com wrote:
> I use generators a lot. E.g.
> 
> 
> def gen_words(text)
>   ... parse text ...
>   yield each word in text
> 
> for word in gen_words(text):
>   print word
> 
> 
> I don't like the name gen_xxx() very much. Looking for some inspiration
> to name generators. Here are some of my ideas:
> 
>   enumerate_words
>   gen_words
>   generate_words
>   parse_words
>   walk_words
> 
> Any idea? Do you have a naming convention for generators?

If it's not a short one where you can see the whole body immediately,
I think it's more important to mention the generator-ness in the
docstring.

Georg



More information about the Python-list mailing list