J. Peng wrote:

> 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

Not all that strange.  The Python equivalent is

x=123
sub test()
     global x
     x=456
test()
print x

Python assignment works by binding an object with a name in a 
namespace.  I suspect that perl does something similar, and the 
differences are in the rules about which namespace to use.

        Mel.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to