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.

Referential Magic in Python

10 pointsby mahipalabout 15 years ago

1 comment

viraptorabout 15 years ago
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 未加载