Feb-28-2021, 04:18 PM
I have a Python list, r[], and would like to define references, or aliases to specific members of the list. This is easy to do in languages with pointers (like C or C++), but I don't see how to do this in Python.
Specifically, I'd like do something like this:
r[0] = 1
ac (=addressof) r[0]
ac = 2
Now if I evaluate r[0] I need it to be 2
Is there a way to define such a reference in Python? I'm not looking for defining a class such that objects of that class can be references to each other. I'm looking for a simple means of pointing one variable to any other variable, but my current specific problem is a reference to a list member.
Specifically, I'd like do something like this:
r[0] = 1
ac (=addressof) r[0]
ac = 2
Now if I evaluate r[0] I need it to be 2
Is there a way to define such a reference in Python? I'm not looking for defining a class such that objects of that class can be references to each other. I'm looking for a simple means of pointing one variable to any other variable, but my current specific problem is a reference to a list member.