V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  XueXianqi  ›  全部回复第 5 页 / 共 5 页
回复总数  84
1  2  3  4  5  
能咬牙么
363 天前
回复了 um1ng 创建的主题 Windows 求推荐 win 平台软件
@jplay 这个 Windows 自带的截图软件确实可以,但是 U1S1 ,唤醒没有 Snipaste 快(需要 0.5 秒左右的时间,有点慢...)
个人见解:

- 不会导致 “循环导入” 的
- 只有 1 个地方用到:偏向于局部导入(避免之后的改动引出“循环导入”)
- 多个地方(>= 2 )用到:顶部导入

- 会导致 “循环导入” 的:只能局部导入
2023-05-29 16:49:07 +08:00
回复了 JasonLaw 创建的主题 Python x in 'aeiou' and y in 'aeiou',有没有更加优雅的写法?
@featureoverload

`all([c in 'aeiou' for c in (x, y)])`看起来优雅,但是性能考虑得不够周全
Python 中有个叫“短路运算”的,`a and b`,如果 a 不成立,就不去运算 b 了,显然这里的 all 用得就不够优雅了
用 all 还需要注意的是:不能完全代替 and ,比如说:
`if a.hasattr("name") and a.name.startswith("A"):`

这里就不能用 all ,如果 a 没有 name 这个 attribute ,就会报错。
1  2  3  4  5  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4990 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 20ms · UTC 09:36 · PVG 17:36 · LAX 02:36 · JFK 05:36
Developed with CodeLauncher
♥ Do have faith in what you're doing.