Object references in Python

In Python you can’t modify a global variable within a function, but you can call object methods that mutate a global object in a function, I think, and I also wanted to confirm that it is a reference to an object that is stored in a collection when you append an object to the collection, just like with arrays. So I fired up the Python REPL…


from collections import deque
class Thang:
    def __init__(self):
        self.about = 'yo
listo = deque()
def fillr():
    th = Thang()
    listo.append(th)
    return

fillr()
listo
deque([<__main__.Thang object at 0x000001DA8A8A9D30>])
    listo[0].about
'yo'