Mike Meyer wrote: > "ex_ottoyuhr" <[EMAIL PROTECTED]> writes: > > I'm trying to create a function that can take arguments, say, foo and > > bar, and modify the original copies of foo and bar as well as its local > > versions -- the equivalent of C++ funct(&foo, &bar). > > C++'s '&' causes an argument to be passed by reference. Python does > that with all arguments. Any changes you make to the argument in the > function will be seen in the caller unless you explicitly make a copy > to pass. > except when foo and bar are bound to immutable objects.
In C: int foo=1; int bar=2; void update(int *a, int *b) { *a=3; *b=4} update(&foo, &bar); In Python: foo=1 bar=2 def update(a,b): a=3; b=4 update(foo,bar) Many people from C/C++ background would be tricked for this situation. -- http://mail.python.org/mailman/listinfo/python-list