TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The Dark Path, Or, What If I Don't Want to Quit My Job?

3 点作者 crux超过 8 年前

1 comment

wyldfire超过 8 年前
&gt; This is rather absurd and I won’t address it any more than to point out that many ordinary programmers intuitively grasp the basic value of safety and specificity, which is why in Python it is widely considered extremely bad practice to write `except:` or `except Exception:` even though having to specify all of the exception classes we are interested in is arguably a safety that we could override at no loss of expressiveness.<p>It takes me a while to unpack this sentence. So I hope I&#x27;m misunderstanding. I think he&#x27;s saying that we could skip out on specifying the exception classes we&#x27;re interested in without losing expressiveness. Expressiveness aside, this is a huge change in functionality.<p>IMO Python probably should&#x27;ve put some kind of damper on `except:` because it&#x27;s almost never what you want. First off, I&#x27;d call this list of classes ones we&#x27;re &quot;prepared to handle&quot; rather than &quot;interested in.&quot; `except:` states boldly &quot;nah, don&#x27;t propagate this up the stack, I know what to do no matter what happened down there.&quot; Using `except:`&#x2F;`except Exception:` is bad because it will catch &quot;UnboundLocalError&quot;, &quot;IndentationError&quot; and several others that are very-nearly unhandle-able elements of the code&#x27;s design. There exists a sliver of a case for a handler in __main__() or somewhere else that can log something though.<p>If he&#x27;s getting at the point of Bob&#x27;s article regarding static typing and testing, then I don&#x27;t see how Python be anything like how it is today and still have some kind of static evaluation of Exceptions-that-could-come-from-this-call.