On Jan 17, 3:34 am, "J. Peng" <[EMAIL PROTECTED]> wrote: > I just thought python's way of assigning value to a variable is really > different to other language like C,perl. :) > > Below two ways (python and perl) are called "pass by reference", but > they get different results. > Yes I'm reading 'Core python programming', I know what happened, but > just a little confused about it. > > $ cat t1.py > def test(x): > x = [4,5,6] >
Hi J, Unlike C or Perl , there is hardly ever any good reason for functions to act by purposefully modifying their arguments. Don't do it. Stick a return in your function and use that result. It is much more maintainable and readable. (It will also work, and look a lot more like, the same function written in other languages :-) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list