"Sandro Dentella" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I'd like to understand why += operator raises an error while .append()
> does
> not.
Your mistake is thinking of '+=' as an operator. In Python terms it is
not, any more than '=' is. In Python, neither 'a=b' nor
Duncan Booth wrote:
> Sandro Dentella wrote:
>
>> I'd like to understand why += operator raises an error while .append()
>> does not. My wild guess is the parses treats them differently but I
>> cannot understand why this depends on scope of the variables (global
>> or class variables):
>
>
>
Sandro Dentella wrote:
> I'd like to understand why += operator raises an error while .append()
> does not. My wild guess is the parses treats them differently but I
> cannot understand why this depends on scope of the variables (global
> or class variables):
>
>
> a = [0]
>
> class foo(object)
Em Dom, 2006-03-05 às 11:49 +, Sandro Dentella escreveu:
> class foo(object):
>
> def __init__(self):
> print "a: ", a
> # += does not work if 'a' is global
> #a += [1]
> a.append(2)
> print "a= ", a
Try with:
a = [0]
class foo(object):
def
I'd like to understand why += operator raises an error while .append() does
not. My wild guess is the parses treats them differently but I cannot
understand why this depends on scope of the variables (global or class
variables):
a = [0]
class foo(object):
def __init__(self):
print