[Tutor] Classes that do operator overloading

Tim Golden mail at timgolden.me.uk
Sat Nov 7 12:46:21 CET 2009

Hugo Arts wrote:
> On Sat, Nov 7, 2009 at 12:25 PM, C.T. Matsumoto <tmatsumoto at gmx.net> wrote:
>> 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.

It's worth stressing that word *guideline*: if you're contributing to
the Python core, PEP 8 is de rigueur; another library or project might
have different standards, more or less derived from PEP 8. If you're
writing your own code, you can do whatever you like. The advantage of
following PEP 8 is that there's one less barrier for someone (including
you, later) following your code. But if you fancy lowercase classes,
use lowercase classses. :)


More information about the Tutor mailing list