[Python-ideas] accurate errors for "magic" methods
jimjjewett at gmail.com
Fri Apr 10 18:11:19 CEST 2009
On 4/10/09, Scott Dial <scott+python-ideas at scottdial.com> wrote:
> Steven D'Aprano wrote:
>> Except that the error "object is unsubscriptable" might as well be in
>> Klingon to most people, particularly newbies.
And newbies shouldn't be worrying about __double_underscore__ names.
> [discussion around http://mail.python.org/pipermail/python-dev/2008-April/078744.html ]
> Perhaps the most relevant part though is GvR saying:
> I wouldn't bet my life on that. __getitem__ overloading for all sorts
> of nefarious purposes has quite a following. I'd prefer a message that
> doesn't get into what x "is" but sticks to the point at hand, which is
> that it doesn't support __getitem__.
Could the message at least mention  as a possible reason that
subscripting or __getitem__ was even called in the first place?
More information about the Python-ideas