no pass-values calling?
J. Peng
peng.kyo at gmail.com
Wed Jan 16 01:51:10 EST 2008
On Jan 16, 2008 2:30 PM, Steven D'Aprano
<steven at remove.this.cybersource.com.au> wrote:
> On Wed, 16 Jan 2008 13:59:03 +0800, J. Peng wrote:
>
> > Hi,
> >
> > How to modify the array passed to the function? I tried something like
> > this:
> >
> >>>> a
> > [1, 2, 3]
> >>>> def mytest(x):
> > ... x=[4,5,6]
>
>
> This line does NOT modify the list [1, 2, 3]. What it does is create a
> new list, and assign it to the name "x". It doesn't change the existing
> list.
>
Sounds strange.
In perl we can modify the variable's value like this way:
$ perl -le '
> $x=123;
> sub test {
> $x=456;
> }
> test;
> print $x '
456
More information about the Python-list
mailing list