Quote:Original post by V E C T O R
Quote:Original post by Fruny
But that's still not going to do what you want, since an assignment to f within your function (like f = open(fileName, fileMode )) will reassign the local reference without affecting the outer f.
Thank you.
At this point, pointers come in to play with C/C++. Is there an equivalent "pointer" within the Python language?
Python's object model is basically like Java's, except without primitives (everything is an object).
There are certainly ways to achieve an extra level of indirection. You can wrap it in any container type, for example. However, you usually don't need to do anything along those lines, because you generally *don't* have copies of objects unless you ask for them:
foo = []bar = [foo] * 3 # every element of bar is the *same* []bar[0].append("spam")print bar # "[['spam'], ['spam'], ['spam']]"print foo # "['spam']"foo = []baz = [copy(foo), copy(foo), copy(foo)] # every element of baz is a *different* *copy* of the [] in foobaz[0].append("spam")print baz # "[['spam'], [], []]"