For example, I have a variable called a, and need to change it by its memory address:
a: str = "hello"
address: int = id(a)
change_by_address(address, a, 'newval') # is something like this possible?
Is there some way to do this, perhaps in the ctypes library?
globals()["a"] = "world"? Would that fit your needs? There is also alocals()version of that as well.id()is not guaranteed to be the memory address of the object, and this is an implementation detail of CPython (though this is almost always the case)