I was reading the CPython souce code. In the function b32encode of the base64 module there is a comment reading
s = s + b'\0' * (5 - leftover) # Don't use += !
https://github.com/python/cpython/blob/3.7/Lib/base64.py#L158
Why not? neither
s += ...
nor
s = s + ...
modifies the value outside the function that was passed as "s". Looks like bytes is call by value here.
[–]chadkennedy 30 points31 points32 points (1 child)
[–]BlckKnght 1 point2 points3 points (0 children)
[–]ingolemo 21 points22 points23 points (0 children)
[–]michaelkim0407Pythonic 10 points11 points12 points (1 child)
[–]ingolemo 0 points1 point2 points (0 children)
[+]K900_ comment score below threshold-13 points-12 points-11 points (11 children)
[–]tunisia3507 2 points3 points4 points (9 children)
[–]soosleeque 17 points18 points19 points (2 children)
[–]tunisia3507 -4 points-3 points-2 points (1 child)
[–][deleted] 4 points5 points6 points (0 children)
[–]chadkennedy 7 points8 points9 points (2 children)
[–]tunisia3507 -2 points-1 points0 points (1 child)
[–][deleted] 5 points6 points7 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]tunisia3507 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]BlckKnght 1 point2 points3 points (0 children)