[Tutor] Classes that do operator overloading
hugo.yoshi at gmail.com
Sat Nov 7 12:35:47 CET 2009
On Sat, Nov 7, 2009 at 12:25 PM, C.T. Matsumoto <tmatsumoto at gmx.net> wrote:
> 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:
Built-in types are only those classes 'built in' to the python
interpreter. They include int, float, str, list, dict, tuple, and
others. Every class you define yourself (and also most classes in the
standard library) should have a Capitalized class name, no matter what
kind of methods you define for it.
> 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.
following the PEP 8 guidelines, that class should have been named Indexer.
More information about the Tutor