CamelCase versus wide_names (Prothon)

Richie Hindle richie at entrian.com
Thu Apr 15 12:07:49 EDT 2004


[Mark]
> could you for the moment pretend you were picking your standard from
> scratch (as we are doing in the Prothon world) and give your vote for which
> you'd prefer?

My preference is for camel case, with initial caps only for class names:

--------------------------------------------

moduleVariable = 3

def myFunction(formalParameter):
    localVariable = None

class MyClass:
    def methodName(self, formalParameter):
        localVariable = None
        self.myAttribute = None

--------------------------------------------

I don't have any scientific backing for that - just "it looks right to me".

That said, 99% of the standard library disagrees with me and uses wide_names
(at least for method names) which is a pretty powerful argument for adopting
that as your standard:

$ egrep "( |\t)+def " *.py | wc
   3353   14222  154294
$ egrep "( |\t)+def [a-z0-9]*[A-Z][a-z0-9]*\(" *.py | wc
     39     148    1645

...OK, 98.837%  8-)

Class names are mostly standardised on CamelCase - hardly any have
underscores:

$ egrep "^class +[^(_]+_[^(]*\(" *.py | wc
     11      45     583

-- 
Richie Hindle
richie at entrian.com





More information about the Python-list mailing list