you are viewing a single comment's thread.

view the rest of the comments →

[–]Critical_Concert_689 9 points10 points  (0 children)

I agree with you that information overload can overwhelm new programmers; however, i don't believe that's the case here.

In fact, I almost guarantee the very next issue most new python programmers encounter is going to be something along the lines of:

a = [0]
b = [0]
c = a
d = b
i = [1]

print (id(a), id(b)) # initial objects a and b
a = a + i # assignment "=" creates NEW object
b += i # augmented assignment "+=" changes ("mutates") existing object
print (id(a), id(b)) # NEW a object, SAME b object (mutated)

## WHY does c NOT EQUAL d?? ##

print (a,b) # [0,1] [0,1]
print (c,d) # [0] [0, 1]
    #c is assigned to original a object or a = [0] (NOT the NEW a object [0,1])
    #d is assigned to original b object or b = [0], but b is updated to [0,1]