There's no way you can do that changing only that line. You can do:

a = [1]
b = a
a[0] = 2
b[0]

That creates a list, assigns the reference to a, then b also, uses the a reference to set the first element to 2, then accesses using the b reference variable.

Answer from Matthew Flaschen on Stack Overflow
🌐
Programshelp
programshelp.com › pages › user-pointer-in-python.html
How to denote pointer in Python, Python reference variable, Python pass by reference, Python dereference pointer, Python pointer to array, Python get value from memory address, Python get object from memory address, Python ctypes pointer, Pointer in Python geeksforgeeks, Python reference and pointers, Python returning memory address, Double pointer in python,
Pointers In Python | Type of Pointers, 14. 22.33333333] mean of arr, axis = 1 : [24. 15. 16.8] out_arr : [0 1 2] mean of arr, axis = 1 : [24 15 16] Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics. To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Top answer
1 of 11
89

There's no way you can do that changing only that line. You can do:

a = [1]
b = a
a[0] = 2
b[0]

That creates a list, assigns the reference to a, then b also, uses the a reference to set the first element to 2, then accesses using the b reference variable.

2 of 11
55

I want form.data['field'] and form.field.value to always have the same value

This is feasible, because it involves decorated names and indexing -- i.e., completely different constructs from the barenames a and b that you're asking about, and for with your request is utterly impossible. Why ask for something impossible and totally different from the (possible) thing you actually want?!

Maybe you don't realize how drastically different barenames and decorated names are. When you refer to a barename a, you're getting exactly the object a was last bound to in this scope (or an exception if it wasn't bound in this scope) -- this is such a deep and fundamental aspect of Python that it can't possibly be subverted. When you refer to a decorated name x.y, you're asking an object (the object x refers to) to please supply "the y attribute" -- and in response to that request, the object can perform totally arbitrary computations (and indexing is quite similar: it also allows arbitrary computations to be performed in response).

Now, your "actual desiderata" example is mysterious because in each case two levels of indexing or attribute-getting are involved, so the subtlety you crave could be introduced in many ways. What other attributes is form.field suppose to have, for example, besides value? Without that further .value computations, possibilities would include:

class Form(object):
   ...
   def __getattr__(self, name):
       return self.data[name]

and

class Form(object):
   ...
   @property
   def data(self):
       return self.__dict__

The presence of .value suggests picking the first form, plus a kind-of-useless wrapper:

class KouWrap(object):
   def __init__(self, value):
       self.value = value

class Form(object):
   ...
   def __getattr__(self, name):
       return KouWrap(self.data[name])

If assignments such form.field.value = 23 is also supposed to set the entry in form.data, then the wrapper must become more complex indeed, and not all that useless:

class MciWrap(object):
   def __init__(self, data, k):
       self._data = data
       self._k = k
   @property
   def value(self):
       return self._data[self._k]
   @value.setter
   def value(self, v)
       self._data[self._k] = v

class Form(object):
   ...
   def __getattr__(self, name):
       return MciWrap(self.data, name)

The latter example is roughly as close as it gets, in Python, to the sense of "a pointer" as you seem to want -- but it's crucial to understand that such subtleties can ever only work with indexing and/or decorated names, never with barenames as you originally asked!

🌐
Real Python
realpython.com › pointers-in-python
Pointers in Python: What's the Point? – Real Python
March 18, 2026 - In this article, you’ll gain a better understanding of Python’s object model and learn why pointers in Python don’t really exist. For the cases where you need to mimic pointer behavior, you’ll learn ways to simulate pointers in Python without the memory-management nightmare.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › python tutorial › pointers in python
Pointers in Python | Type of Pointers | Arithmetic Operations
August 23, 2025 - Variables which serve the special purpose of storing the address of other variables, pointing to the address of the variable of which the address is provided, with obtaining of the value stored at the location being called dereferencing, like a page number in the index of a book that drives the reader to the required content, with performance for repetitive operations like traversing data structures being significantly improved, especially in terms of time and space constraints, supporting the copy and access operations effectively, and are indirectly supported as a concept by Python programming language are termed as pointers in Python.
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
GeeksforGeeks
geeksforgeeks.org › python › using-pointers-in-python-using-ctypes
Using Pointers in Python using ctypes - GeeksforGeeks
July 23, 2025 - Since in Python the concept of pointers is not properly available or used we can't properly create a Void Pointer, as the POINTER function requires one argument i.e the data type. But we can create a Void pointer of a certain data type and then don't point it to any memory address.
🌐
Launch School
launchschool.com › books › python › read › variables_pointers
How Python objects and variables really work
You can say that a variable points to or references an object in memory, and you can also say that the pointers stored in variables are references. Some languages make a distinction between references and pointers, but Python does not; feel free to use either term.
Find elsewhere
🌐
Quora
quora.com › How-do-I-create-pointers-in-Python
How to create pointers in Python - Quora
Answer (1 of 7): It is not necessary, as labels will function as references to values automatically. Python restricts references to always point to some value. You cannot make a reference without an initializing value, even if it is [code ]None[/code]. Python functions return [code ]None[/code] b...
🌐
Anvil
anvil.works › articles › pointers-in-my-python-1
Memory Management in Python - Part 1: What Are Pointers?
For the purposes of this series of articles, we don’t need to worry about scopes; we can assume all our examples take place in the global namespace. Pointers can be thought of as names - that is, entries in Python’s namespace - that correspond to objects in Python’s memory.
🌐
Nickmccullum
nickmccullum.com › python-pointers
How to Use Python Pointers | Nick McCullum
June 13, 2020 - Objects in Python are of two types – Immutable and Mutable. It is important to understand the difference between immutable and mutable objects to implement pointer behavior in Python.
🌐
The Coding Forums
thecodingforums.com › programming languages › python
Pointers in python? | Python | Coding Forums
February 8, 2024 - AFAIK in python, variables are references to objects, and when you assign a variable to another, it essentially points to the same object. However, in your example, you are creating a dictionary, and modifying the score variable won't automatically update the dictionary since dictionaries are immutable. If you want to achieve something similar to a pointer in python, you might want to use a mutable object for example like a list.
🌐
Python Morsels
pythonmorsels.com › pointers
Variables and objects in Python - Python Morsels
February 28, 2022 - In Python a pointer just represents the connection between a variable and an object. Imagine variables living in variable land and objects living in object land. A pointer is a little arrow that connects each variable to the object it points to.
🌐
Python Morsels
pythonmorsels.com › variables-are-pointers
Variables are pointers in Python - Python Morsels
July 18, 2026 - These are all terms that you'll hear used to describe how variables work in Python. Regardless of what word you use to describe the relationship between variables and objects, make sure not to use the mental model of a variable containing an object. Variables are not like buckets in Python. Instead, they're pointers.
🌐
CodeSpeedy
codespeedy.com › home › understanding pointers in python
Understanding Pointers In Python - CodeSpeedy
January 30, 2020 - This is the place where you are going to find the full explanation of pointers in Python. Actually, here in Python pointers are nothing but variables.
🌐
Ned Batchelder
nedbatchelder.com › blog › 202403 › does_python_have_pointers
Does Python have pointers? | Ned Batchelder
March 11, 2024 - People sometimes ask, “Does Python have pointers?” I hate to be the typical senior engineer, but this is one of those questions where the answer is, it depends what you mean by pointer. The classic definition of a pointer is: a variable that holds the address of something else and that you can use to work with that something else. In very broad pseudo-code, it would be something like this:
🌐
Python
docs.python.org › 2.5 › lib › ctypes-pointers.html
14.14.1.14 Pointers
December 23, 2008 - Pointer instances have a contents attribute which returns the object to which the pointer points, the i object above:
🌐
YouTube
youtube.com › watch
Pointers in Python Are A Real Thing - YouTube
In this video, we learn how to use C-pointers in Python.◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾📚 Programming Books & Merch 📚🐍 The Python Bible Book: https://www.neuralnine.com/...
Published: December 13, 2022
🌐
Edureka Community
edureka.co › home › community › categories › python › pointers in python
Pointers in Python | Edureka Community
August 20, 2018 - I know Python doesn't have pointers, but is there a way to have this yield 2 instead >>> ... not completely necessary, but I think it would be nice.
🌐
Europython
ep2024.europython.eu › session › pointers-in-python
Pointers in Python
July 8, 2024 - Remember pointers from C/C++? Why don’t we add them to Python? Make any Python object mutable by manipulating it directly in memory through the pointer as you would do in C/C++. Why do this? Well, pointers have no use in Python, but the point is not implementation itself, but all the internal parts of Python programming language that you will touch while implementing it.