[Python-Dev] unsubscriptable vs object does not support indexing (original) (raw)
Brett Cannon brett at python.org
Thu Sep 24 00:00:07 CEST 2009
- Previous message: [Python-Dev] unsubscriptable vs object does not support indexing
- Next message: [Python-Dev] unsubscriptable vs object does not support indexing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Sep 23, 2009 at 14:49, Michael Foord <fuzzyman at voidspace.org.uk> wrote:
Brett Cannon wrote:
On Wed, Sep 23, 2009 at 14:19, Michael Foord <fuzzyman at voidspace.org.uk> wrote: [SNIP]
Also +1. I had a friend (an experienced programmer) who started using Python recently. The cryptic nature of some of the error messages was a sore point with him. Do you know which error messages? We can change them. We have always said that we view exception messages as something that can change in minor releases and that you should be very careful if you ever use them in tests. There were a couple and I can only remember the last one he talked about. He ran some code with "python -3" that used someone else's library and resulted in the following warning, that he felt was cryptic: DeprecationWarning: Overriding eq blocks inheritance of hash in 3.x Hmm... not entirely sure how we can make it clearer. There is a great blog entry on the subject by Eric Lippert though (Microsoft I'm afraid): http://blogs.msdn.com/ericlippert/archive/2006/07/07/659259.aspx Error messages: diagnostic is preferable to prescriptive * Polite: making the user feel like an idiot is very, very bad. * Readable: poor grammar and tortured sentence structure is bad. * Accurate: error messages must accurately describe the problem. * Precise: "Something is wrong" is an accurate error message but not a very precise one! * Diagnostic but not prescriptive: describe the problem, not the solution. How about (?): If you implement equality (eq) you should also implement hashing (hash), it won't be inherited in 3.x. Although that is prescriptive of course...
So the original makes sense if you are implementing an object's comparison operator. But if you are not it won't make much sense, although if you are not implementing it then it shouldn't be your concern. Then again, if you are trying to upgrade your code and some library you used has not, I can see how that message would throw you for a loop.
So +0 on your specific improvment and +1 for trying to think about newbies when writing exception messages.
-Brett
- Previous message: [Python-Dev] unsubscriptable vs object does not support indexing
- Next message: [Python-Dev] unsubscriptable vs object does not support indexing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]