Re: assigning values in python and perl

2008-01-22 Thread Antoon Pardon
On 2008-01-17, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 17 Jan 2008 11:40:59 +0800, J. Peng wrote: > >> May I ask, python's pass-by-reference is passing the object's reference >> to functions, but perl, or C's pass-by-reference is passing the variable >> itself's reference to functions.

Re: assigning values in python and perl

2008-01-17 Thread George Sakkis
On Jan 17, 1:59 am, Christian Heimes <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > Posting a counter-example where the difference is clearly shown would > > be more vastly useful than referring to a list of long obscure usenet > > posts with practically no examples. C/C++ are not even menti

Re: assigning values in python and perl

2008-01-16 Thread J. Peng
On Jan 17, 2008 2:55 PM, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > > @$ref = (4, 5, 6) intentionally assigns to the same list pointed to by > the reference. That would be spelled as x[:] = [4, 5, 6] in Python. > What Python does in your example is assign the same as Perl's $ref = > [4, 5, 6]. So

Re: assigning values in python and perl

2008-01-16 Thread Hrvoje Niksic
"J. Peng" <[EMAIL PROTECTED]> writes: > $ cat t1.py > def test(x): > x = [4,5,6] > > a=[1,2,3] > test(a) > print a > > $ python t1.py > [1, 2, 3] > > $ cat t1.pl > sub test { > my $ref = shift; > @$ref = (4,5,6); > } @$ref = (4, 5, 6) intentionally assigns to the same list pointed to

Re: assigning values in python and perl

2008-01-16 Thread Christian Heimes
George Sakkis wrote: > Posting a counter-example where the difference is clearly shown would > be more vastly useful than referring to a list of long obscure usenet > posts with practically no examples. C/C++ are not even mentioned in > that page. I am not claiming you are wrong, I just don't find

Re: assigning values in python and perl

2008-01-16 Thread George Sakkis
On Jan 17, 1:03 am, Christian Heimes <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > Python's parameter passing is like passing a pointer in C/C++. > > [snip] > > It's not (I repeat NOT) like passing a pointer in C. Please > readhttp://effbot.org/zone/call-by-object.htm > > Christian Posti

Re: assigning values in python and perl

2008-01-16 Thread Paddy
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 'C

Re: assigning values in python and perl

2008-01-16 Thread J. Peng
On Jan 17, 2008 1:54 PM, Mel <[EMAIL PROTECTED]> wrote: > > test(a) (along with def test(x)) takes the object named 'a' in the > current namespace and binds it with the name 'x' in function test's > local namespace. So, inside test, the name 'x' starts by referring to >the list that contains [

Re: assigning values in python and perl

2008-01-16 Thread J. Peng
On Jan 17, 2008 2:03 PM, Christian Heimes <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > Python's parameter passing is like passing a pointer in C/C++. > [snip] > > It's not (I repeat NOT) like passing a pointer in C. Please read > http://effbot.org/zone/call-by-object.htm > Yes I agree. No

Re: assigning values in python and perl

2008-01-16 Thread Christian Heimes
George Sakkis wrote: > Python's parameter passing is like passing a pointer in C/C++. [snip] It's not (I repeat NOT) like passing a pointer in C. Please read http://effbot.org/zone/call-by-object.htm Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: assigning values in python and perl

2008-01-16 Thread Mel
J. Peng wrote: > May I ask, python's pass-by-reference is passing the object's > reference to functions, but perl, or C's pass-by-reference is passing > the variable itself's reference to functions. So althought they're all > called pass-by-reference,but will get different results.Is it? > > On Ja

Re: assigning values in python and perl

2008-01-16 Thread George Sakkis
On Jan 16, 10:34 pm, "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. > > (snipped) Pyt

Re: assigning values in python and perl

2008-01-16 Thread Steven D'Aprano
On Thu, 17 Jan 2008 11:40:59 +0800, J. Peng wrote: > May I ask, python's pass-by-reference is passing the object's reference > to functions, but perl, or C's pass-by-reference is passing the variable > itself's reference to functions. So althought they're all called > pass-by-reference,but will ge

Re: assigning values in python and perl

2008-01-16 Thread J. Peng
May I ask, python's pass-by-reference is passing the object's reference to functions, but perl, or C's pass-by-reference is passing the variable itself's reference to functions. So althought they're all called pass-by-reference,but will get different results.Is it? On Jan 17, 2008 11:34 AM, J. Pen

assigning values in python and perl

2008-01-16 Thread J. Peng
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 con