[Tutor] Classes that do operator overloading

Hugo Arts hugo.yoshi at gmail.com
Sat Nov 7 12:16:20 CET 2009


On Sat, Nov 7, 2009 at 10:39 AM, C.T. Matsumoto <tmatsumoto at gmx.net> wrote:
> yes,
>
> class Foo: # the book says this is a class header
>   pass
>
> As for my question it looks like the convention is if a class only has
> operator overloading then the class receives a lowercase class name.
> If the class has a mix, operator overloading and a normal method then
> the class name gets starts with a capital.
>
> It's just a detail, but I wanted to know.
>

class names should always be capitalized, no matter what kind of
methods they have.
The exceptions to this are the built-in types (int, str, list, dict,
etc.). But if you're writing a class yourself,
capitalize it.

quoting PEP 8:

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

if you want to know something, anything at all about style
conventions, read PEP 8. It's the definitive python styleguide.

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

Hugo


More information about the Tutor mailing list