Message373672
Sorry Yashwanthbarad, this isn't a bug, you expect the wrong result.
Augmented assignment for lists is documented to be the same as calling the extend method, which means your AppenedFuncShortHandOperator function modifies the argument list in-place.
The AppenedFuncRegularAssignment simply replaces the *local variable* inside the function with a new list. Since it doesn't return the new list, the new list gets thrown away when the function returns, leaving the original list untouched.
This is not a bug, it is the normal behaviour. If you need help understanding why it works the way it does, and the difference between mutating an object and binding a new object to a local variable, there are many places you can ask for help, such as Stackoverflow, the /learnpython sub-reddit on Reddit, the tutor mailing list and others.
https://mail.python.org/mailman/listinfo/tutor
Good luck! |
|
Date |
User |
Action |
Args |
2020-07-15 08:28:02 | steven.daprano | set | recipients:
+ steven.daprano, paul.moore, tim.golden, zach.ware, steve.dower, yashwanthbarad@gmail.com |
2020-07-15 08:28:02 | steven.daprano | set | messageid: <1594801682.82.0.757883400638.issue41301@roundup.psfhosted.org> |
2020-07-15 08:28:02 | steven.daprano | link | issue41301 messages |
2020-07-15 08:28:02 | steven.daprano | create | |
|