On Mon, Feb 28, 2005 at 11:32:22AM -0700, Steven Bethard wrote: > [EMAIL PROTECTED] 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.) > Ditto for me, plural implies list and singular implies instance, for (contact) in contacts: # do something with contact
But I tend to name dictionaries as "key_to_value" as in "email_to_contact" or "ip_to_hostname." for (email) in emails: contact = email_to_contact[email] # do something with contact It may seem verbose but I can type much faster than I can think and it makes reading even forgotten code a breeze. -Jack -- http://mail.python.org/mailman/listinfo/python-list