--- On Thu, 11/25/10, Steve Holden <st...@holdenweb.com> wrote: > > Sometimes the golden rule in Python of > > "explicit is better than implicit" is > > so cheap that it can be thrown away > > for the trouble of typing an empty tuple. > > > I'm not sure that there *are* any golden rules. The "Zen of > Python" is > intended to be guidelines, not rigid rules intended to > constrain your > behavior but advice to help you write better code. > > > Surely an exaggeration. In fact current best practice > (which you should > inform yourself of as best you can to help you in your > teaching work - > so you are to be congratulated for bringing this question > to the list) > is to always use explicit calls, with arguments specifying > a tailored > message. > > regards > Steve
A very cogent message -- the end echos the start. :) I must say that I learned from you a new angle to think about this issue. On the other hand, I still feel that when allowing both ways colliding into the simpleness and bueaty of the language, we should consider to make a decision. Sure, this introduced quite a lot of complexity when the doc has to give a very long explanation of what is happening in order to justify it. As I am thinking about it, it seems two conflicting intuition of code comprehension are at work here: Intuition #1: as if you raise an exception type, and then match that type. It seems that no instances are involved here (Intuitively). See an example code here: try: raise KeyError except KeyError: pass Intuition #2: you raise an exception instance, and then match an instance by its type. See an example code here: try: raise KeyError() except KeyError as ke: pass Those two comprehensions are not compatible, and thus the one that promotes correct understanding should be encouraged, while the other should be discouraged, and maybe even be made iliegal. Regards, Yingjie -- http://mail.python.org/mailman/listinfo/python-list