Thanks Hugo,

Do methods like __add__, __del__, count as built-in types? I'm aware of the
rule you explained and use it and that's why when  I saw:

class indexer():
    def ___getitem__(self, index):
        return index ** 2

I thought I was missing some special style, or rule. The class above is take
from Learning Python, and there are several other examples too.

Thanks,

T
Hugo Arts wrote:
On Sat, Nov 7, 2009 at 10:39 AM, C.T. Matsumoto <tmatsum...@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


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to