MRAB wrote: > andrew cooke wrote: >> R. David Murray wrote: >>>> [...] >>>> try: >>>> dimensions.append(float(s)) >>>> except: >>>> dimensions.append(float(quantization[s])) >>> No, no, no; never use a bare except! :) >> >> can you explain why? i can't think of any reason why the code would be >> better catching a specific exception. >> >> as a general rule, maybe, but in this particular case i can't see a >> reason >> - so i'm not sure if you're just pedantically following rules or if i've >> missed something i should know. >> > A bare exception will catch _any_ exception, even those you didn't > expect (technical term: "bug" :-)); for example, if you had written: > > try: > dimension.append(float(s)) > except: > dimensions.append(float(quantization[s])) > > it would silently catch "NameError: name 'dimension' is not defined" and > perform the fallback action.
true, i hadn't considered coding errors (i was thinking that something global, like out of memory, would fail again anyway). andrew -- http://mail.python.org/mailman/listinfo/python-list