Naming conventions for functions and methods

Ben Finney ben at benfinney.id.au
Tue Jul 8 19:59:22 EDT 2014


python at bdurham.com writes:

> Looking for your opinions on how you name your functions and
> methods. Example: I have a function that hashes a file. I could
> name this function hash_file() or file_hash().

I'd prefer just ‘hash’. The function name can be considered an action
verb, with its arguments as the objects acted upon.

-- 
 \     “Nothing worth saying is inoffensive to everyone. Nothing worth |
  `\    saying will fail to make you enemies. And nothing worth saying |
_o__)            will not produce a confrontation.” —Johann Hari, 2011 |
Ben Finney




More information about the Python-list mailing list