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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

How to think like a Pythonista

45 点作者 mahipal大约 15 年前

4 条评论

j_baker大约 15 年前
"there is really no alternative in the general case without imposing huge overhead, making copies of everything "just in case"."<p>Actually, there is an alternative: use persistent data structures. Granted, it's an alternative that isn't terribly "Pythonic", but an alternative nonetheless.
d0mine大约 15 年前
A terser version with pictures: <a href="http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#other-languages-have-variables" rel="nofollow">http://python.net/~goodger/projects/pycon/2007/idiomatic/han...</a> from "Code Like a Pythonista: Idiomatic Python" by David Goodger
JshWright大约 15 年前
Seems like a very verbose way to explain the situation to the original poster...<p>Lists are mutable, strings aren't. When you reassign one of the dictionary values pointing to an existing string, it can't change that string, so it creates a new one. Since lists can be changed, it doesn't need to create a new one and can modify the existing list.
评论 #1275199 未加载
samratjp大约 15 年前
Obligatory: <a href="http://code.google.com/edu/languages/google-python-class/" rel="nofollow">http://code.google.com/edu/languages/google-python-class/</a>