strange behavor....

Chris Rebert clp2 at rebertia.com
Sat Nov 13 15:44:58 EST 2010


On Sat, Nov 13, 2010 at 5:46 AM, Tracubik <affdfsdfdsfsd at b.com> wrote:
> hi all,
> i've this on python 2.6.6:
>
>>>> def change_integer(int_value):
> ...     int_value = 10
> ...
> ... def change_list(list):
> ...     list[0] = 10
> ...
> ... a = 1
> ... l = [1,1,1]
> ...
> ... change_integer(a)
> ... change_list(l)
> ...
> ... print a
> ... print l
> 1
> [10, 1, 1]
>
> why the integer value doesn't change while the list value do?
> in Pascal i can choose the behavour of parametres, how this work on Python?
> also a link could be appreciated

http://effbot.org/zone/call-by-object.htm

Cheers,
Chris



More information about the Python-list mailing list