"always passes by reference"

Greg Weeks weeks at golden.dtc.hp.com
Tue Jul 25 21:10:15 EDT 2000


(Greg Weeks) (weeks at golden.dtc.hp.com) wrote:
: I prefer the old way of speaking.  With the new way of speaking, both
: Python and Perl are "pass by reference", but Perl is somehow *more* so.

If it isn't clear what I mean, here's some Perl:

    sub f
    {
        $_[0] = 42;
    }

    $x = 1;
    f($x);
    print "$x\n";		# PRINTS 42

and the corresponding Python:

    def f(a):
	a = 42

    x = 1
    f(x)
    print x			# PRINTS 1

Good Python!  Bad Perl!

Greg



More information about the Python-list mailing list