Use self.vars in class.method(parameters, self.vars)

rantingrick rantingrick at gmail.com
Fri Jul 22 14:38:21 EDT 2011


On Jul 22, 10:43 am, "bruno.desthuilli... at gmail.com"
<bruno.desthuilli... at gmail.com> wrote:
>
> class names should start with an uppercase letter:

WRONG! Class identifiers should use the capwords convention

 * class Foo
 * class FooBar
 * class FooBarBaz

--------------------------------------------------
 PEP8.Naming_Conventions.Class_Names
--------------------------------------------------
Almost without exception, class names use the CapWords convention.
Classes for internal use have a leading underscore in addition.
--------------------------------------------------

Make sure to follow this directive to a "T" because if you don't, i
can assure you that you will regret it! I would actually change
"Almost without exception" to "WITHOUT EXCEPTION" myself. Actually in
RickPy4000 naming conventions are going to be enforced -- follow them
or die of exceptions.


*Case in point:*
Some folks refuse to cap "all" words because they "think" some words
are actually a single "compound word". And in the real world they are
correct but in the case sensitve world of programming this can bite
you in the arse later.

Consider:
 class Messagebox
 class Listview
 class Combobox
 class ScrolledTextbox

Now later on when you are writing some code you cannot remember which
words you capped and which you did NOT cap. Best thing to do is ALWAYS
cap every word. In other words, be consistent!
 class MessageBox
 class ListView
 class ComboBox
 class ScrolledTextBox

*school-bell-rings*

PS: Someone needs to create links in the PEP for faster navigation to
topic of interest OR we need to create a new module called
"styleguide.py"

>>> import styleguide
>>> styleguide.naming_conventions('class')
"Almost without exception, class names use the CapWords convention.
Classes for internal use have a leading underscore in addition."

PEP8: http://www.python.org/dev/peps/pep-0008/




More information about the Python-list mailing list