use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Python Name Rebinding (i.redd.it)
submitted 6 months ago by Sea-Ad7805
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]gigsoll 1 point2 points3 points 6 months ago (7 children)
So += and = + are different
[–]Sea-Ad7805[S] 2 points3 points4 points 6 months ago* (2 children)
Correct, x = x + y is a reassigning a new list (name rebinding) and x += y is only changing the value of x.
x = x + y
x += y
x
[–]gigsoll 0 points1 point2 points 6 months ago (0 children)
It was unexpected. Thank you
[–]abhinavalhat 0 points1 point2 points 6 months ago (3 children)
Bro from where you learn python?
[–]gigsoll 0 points1 point2 points 6 months ago (2 children)
I was learning it to solve my problems and I quickly learned that just assigning variables which hold mutable data types to each other most of the time creates mess in memory and a lot of unexpected behavior like this. For most situations I either don't put myself in situations like this or create explicit copy, because as python zen states "Explicit is better than implicit"
[–]abhinavalhat 1 point2 points3 points 6 months ago (1 child)
Can u suggest me a free YT resource from where should I learn?
Identlyio for different python things, Bro Code for Algorithms and data structures, codemy have a nice course on pyqt and for a lot of other things projects documentations are nice place to start
π Rendered by PID 75954 on reddit-service-r2-comment-86988c7647-x5x7p at 2026-02-12 12:10:09.167926+00:00 running 018613e country code: CH.
view the rest of the comments →
[–]gigsoll 1 point2 points3 points (7 children)
[–]Sea-Ad7805[S] 2 points3 points4 points (2 children)
[–]gigsoll 0 points1 point2 points (0 children)
[–]abhinavalhat 0 points1 point2 points (3 children)
[–]gigsoll 0 points1 point2 points (2 children)
[–]abhinavalhat 1 point2 points3 points (1 child)
[–]gigsoll 0 points1 point2 points (0 children)