TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How to think like a Pythonista

45 pointsby mahipalabout 15 years ago

4 comments

j_bakerabout 15 years ago
"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.
d0mineabout 15 years ago
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
JshWrightabout 15 years ago
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 未加载
samratjpabout 15 years ago
Obligatory: <a href="http://code.google.com/edu/languages/google-python-class/" rel="nofollow">http://code.google.com/edu/languages/google-python-class/</a>