Archives for the Date February 22nd, 2008

Learning Python: Chapter 16

 

Perl
Python

my $x = 10;
sub foo
{
$x = 20;
}

x = 10
def foo():
global x
x = 20

Declaring a variable in a function as global is only necessary for reassignments, not for mere read-access.
def foo(x, y, z): pass
foo(10, 20, 30)
does the same as
[...]