*Naming Conventions*

Thorsten Kampe thorsten at thorstenkampe.de
Mon Jun 4 06:03:39 CEST 2007


I hear you saying 'not another naming conventions thread'. I've read 
through Google and the 'naming conventions' threads were rather 
*spelling conventions* threads.

I'm not interested in camelCase versus camel_case or anything 
mentioned in  'PEP 8 -- Style Guide for Python Code'. What I'm looking 
for is hints or ideas how to name your variables and especially how to 
name functions, methods and classes.

I know this depends on what the function is doing. If I know what it 
is doing I should be able to give them a desciptive name. But actually 
I'm often not able. Especially when the task is quite similar to 
another function or Class.

Recently I wrote this code and noticed that I was completely lost in 
giving these objects names to describe and distinguish them:

for validanswer in validanswers:
    if myAnswers.myanswer in myAnswers.validAnswers[validanswer]:
        MyOptions['style'] = validanswer

The 'tips' I got through some postings or articles on the net are: if 
a function simply tests something and returns a boolean call it

def is_<whatever_you_are_testing_for>():

like 'is_even'.

Makes sense. The other thing I captured was to use something like

def get_values():

... Makes sense, too, but aren't all functions getting something?

So if someone had a similar dilemma to mine and could tell me how he 
dealt with that, I'd be grateful...


More information about the Python-list mailing list