On Nov 8, 6:21 am, greg <[EMAIL PROTECTED]> wrote: > Arnaud Delobelle wrote: > > 'Pass by value' is not relevant to Python as variables do not contain > > anything. > > Where abouts in the phrase "pass by value" does the word > "contain" appear?
You don't quote enough context for it to appear. > You don't need a notion of containment in order for > "pass by value" to have meaning. All you need is some > notion of a "value" (it doesn't matter what) and > some way to "pass" that value. > > > 'Pass by reference' is not relevant to Python as the language > > doesn't have the concept of object reference (in the sense of e.g. C++ > > reference). > > What it doesn't have is the concept of a *variable* > reference, which is what the "reference" in "pass by > reference" means. What's a variable reference? > > Here lies, IMHO, the reason why you think you need Python to 'pass by > > value'. As you believe that variables must contain something, you think > > that assignment is about copying the content of a variable. Assignment > > in Python is simply giving a new name to an object. > > Yes, and so is passing by value! What you're saying is that in the code below, when foo(q) is called then 'p' in foo is another name for q in main. Right? struct point { int x; int y; } int foo(point p) { p.x = 42; } int main() { point q = {0, 0}; foo(q); /* So now you're saying that q.x == 0 ? */ } -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list