Greg Ewing wrote: > Nick Coghlan wrote: >> For example, simply >> replacing 'index' with 'integer' could lead to a different kind of >> confusion: TypeError: 'float' object cannot be interpreted as an >> integer > > Maybe something like > > TypeError: 'float' object cannot be used as an integer in this > context
Going back to the original proposal: >>> x = b'a' >>> x[0] = b'a' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'bytes' object cannot be used as an integer in this context Not too bad. +1 as a default. > Or maybe require the caller to pass in an error message > format, or at least have a version of the call which > allows that. +1 >>> x = b'a' >>> x[0] = b'a' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Cannot assign 'bytes' object to 'bytes' element >>> x = b'a' >>> x[0] = [1] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Cannot assign 'list' object to 'bytes' element Tim Delaney _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com