Curious function argument
nomail at invalid.com
Wed Nov 12 14:07:14 CET 2014
I saw in a code from a previous message in this forum
a curious function argument.
print(x) ## Poor man's object
x += 1
I understand that the author wants to implement a global
variable x . It would be better to write 'global x' inside the
At first test() function call, it prints 0, that's OK.
But at the second call, since we dont pass any argument to test(),
x should be equal to its default value  (a single item list). But
it seems that Python keeps the original object whose content has
been changed to 1.
Is it a usual way to implement a global variable ?
More information about the Python-list