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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Referential Magic in Python

10 点作者 mahipal大约 15 年前

1 comment

viraptor大约 15 年前
I think the article makes the matter more confusing than it should be. Actually many people make it more confusing. Just like with Java, Python passes only values. The value can be a reference to an object sometimes - that's pretty much it. Just like with Java, the call-by-whatever is sometimes misunderstood. It never behaves like call-by-reference. You can never do:<p><pre><code> def a(x): x = 42 </code></pre> and expect the value of `y` in your local scope to be changed after `a(y)`.<p>I'd rather agree with the way Java defines it - call by value.<p>Wikipedia: <i>However, the term "call by sharing" is not in common use; the terminology is inconsistent across different sources. For example, in the Java community, they say that Java is pass-by-value, whereas in the Ruby community, they say that Ruby is pass-by-reference, even though the two languages exhibit the same semantics.</i>
评论 #1351202 未加载
评论 #1350914 未加载