nlimpid

nlimpid

V2EX member #66356, joined on 2014-06-27 13:24:35 +08:00
Per nlimpid's settings, the topics list is hidden
Deals info, including closed deals, is not hidden
nlimpid's recent replies
Jun 24, 2025
Replied to a topic by yujianwjj Python go 转 Python 的心智负担增加
我对 Python 也不是很熟悉,不过我还是认为 Python 的错误处理更好些。

1. Go 的这种显式的把 Err 当成返回值的设计选择会让代码变的啰嗦一些。对于题主的例子来说,Python 生态可以根据不同的场景选择每一次处理都抛异常或者把异常合并在一起,让 Happy Path 更加清楚。



```
try:
result = foo()
do_something(result) // 这里也可以每次都 try ,和 Go 就一样了。
except FooError as e:
```

2. 我认为题主的这句话「很多时候,我跳转到函数的源码里面,也看不出会返回什么异常」是因为对语言熟悉程度导致的。我常写 Go 就知道常见的 io.EOF, os.ErrNotExist 。但从实际文档来看可能差异不大,以 JSON 为例,Python Doc 把 Exception 都放一起来相对来说还好找些。https://docs.python.org/3/library/json.html#exceptions https://pkg.go.dev/encoding/json#MarshalerError
Mar 16, 2021
Replied to a topic by psw84 推广 NUC8i5 黑果套餐返场! 抽一人送西数黑盘.
2T 硬盘+硬改,性价比很高了
新年快乐
更接近一个给自己看的 twitter/weibo,挺好的
Nov 29, 2020
Replied to a topic by psw84 推广 NUC 黑果套餐 继续开车 有福利!
已经有一套了,除了凑数更希望开车一个便携显示器最终呈现一个完整的体验
网站维护中

Down for Maintenance (Err 3)
如果只有 ipv4,用 int 就够了。
如果同时有 ipv4 和 ipv6,可以使用 varbinary(16),mysql 有内置的方法处理 ip 类型,见 https://dev.mysql.com/doc/refman/5.6/en/miscellaneous-functions.html
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5494 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 14ms · UTC 07:51 · PVG 15:51 · LAX 00:51 · JFK 03:51
♥ Do have faith in what you're doing.