naming convention for scalars, lists, dictionaries ...

Steven Bethard steven.bethard at gmail.com
Mon Feb 28 13:32:22 EST 2005


beliavsky at aol.com wrote:
> Since Python does not have declarations, I wonder if people think it is
> good to name function arguments according to the type of data structure
> expected, with names like "xlist" or "xdict".

In general, I find that naming collections for their contents is much 
more useful than some abbreviated type prefix.  However, while I don't 
name objects by their type, I do tend to name iterables with plurals 
(e.g. "words", "feature_indices", "events", etc.) and I typically suffix 
mapping types with "map" (e.g. "word_index_map", "event_relation_map", 
"prime_factor_map", etc.)

STeVe



More information about the Python-list mailing list