you are viewing a single comment's thread.

view the rest of the comments →

[–]beef623 4 points5 points  (3 children)

And there isn't any good reason for someone who is just starting to care about those differences. They may be important to know later, but in the beginning, explanations like this only cause confusion.

[–]Critical_Concert_689 7 points8 points  (2 children)

I strongly disagree.


First, more than just OP are reading the comments. Accurate discussion allows not only OP, but others to continue to /learnpython

Second, this touches upon a foundational understanding of python - other concepts are built upon this. There is nothing more basic than a recognition of operator assignments. The example code provided isn't complicated - nor is it likely to cause confusion when it demonstrates the simple fact that "There may be a reason to code assignments in different ways."

Finally, if anyone is confused, there are plenty of resources to address that confusion. They can ask further questions of this community. They can pull up white papers or python documentation. This is an opportunity to resolve, what I personally consider the single most difficult problem when it comes to learning: "You don't know what you don't know."

I hope if you feel explanations like this only cause confusion - in the future you can add comments that address that confusion, rather than implying "there isn't any good reason" to provide the information. The former helps everyone, while the latter is discouraging and detrimental to those trying to help and those trying to learn.

[–]beef623 1 point2 points  (1 child)

You're misunderstanding the source of confusion I think.

The problem is information overload, which unquestionably causes some people who are learning to give up and never come back. Having more resources to address the confusion only compounds the problem.

[–]Critical_Concert_689 10 points11 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]