[Python-Dev] unsubscriptable vs object does not support indexing
Dino Viehland
dinov at microsoft.com
Wed Sep 23 02:23:56 CEST 2009
More information about the Python-Dev mailing list
Wed Sep 23 02:23:56 CEST 2009
- Previous message: [Python-Dev] how to properly object to something (was: Distutils ML wrap-up: setup.cfg new format)
- Next message: [Python-Dev] unsubscriptable vs object does not support indexing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Is there a reason or a rule by which CPython reports different error message for different failures to subscript? For example: >>> set()[2] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'set' object does not support indexing >>> class c(object): pass ... >>> c()[2] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'c' object does not support indexing But compare this to: >>> [].append[42] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'builtin_function_or_method' object is unsubscriptable >>> (lambda: 42)[42] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'function' object is unsubscriptable >>> property()[42] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'property' object is unsubscriptable IronPython had a bug report that we were getting this wrong for set objects and that "does not support indexing" was also a clearer error message. I'm wondering if there's some reason why the different error messages occur which I'm missing. Otherwise I could switch to using the more clear message or start marking types which should report the unsubscriptable error. Does anyone have any insights into this? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20090923/dbb5efab/attachment.htm>
- Previous message: [Python-Dev] how to properly object to something (was: Distutils ML wrap-up: setup.cfg new format)
- Next message: [Python-Dev] unsubscriptable vs object does not support indexing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list