On 23 September 2013 22:14, Skip Montanaro <skip@pobox.com> wrote:
>> Should pylint really be this strict? Or am I expected to implement
>> everything necessary for an array-like containiner and just raise
>> exceptions in those methods the user really shouldn't access?
>
> No I'ld say you're right. While it sounded a good idea when proposed, you're not
> the first one being confused by this message, so I tend to think this check
> should be either removed or kept for well defined and all-or-nothing protocols
> (the only one coming to my mind being the context manager __enter__ / __exit__,
> but there may be others). I would be glad to have others'opinion though.

It occurs to me that the reverse case is likely still correct.  That
is, if __getitem__ is defined, omitting __len__ should happen only
rarely, and probably require an explicit suppression somewhere,
probably in the class definition.


Several times I've implemented classes with dynamic behaviour in __getitem__, so they have no strict length (beyond "theoretically infinite").

Michael
 

Skip
_______________________________________________
code-quality mailing list
code-quality@python.org
https://mail.python.org/mailman/listinfo/code-quality



--
http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html