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
🌐
Real Python
realpython.com › pointers-in-python
Pointers in Python: What's the Point? – Real Python
March 18, 2026 - Pointers are widely used in C and C++. Essentially, they are variables that hold the memory address of another variable. For a refresher on pointers, you might consider checking out this overview on C Pointers. In this article, you’ll gain a better understanding of Python’s object model and learn why pointers in Python don’t really exist.
🌐
W3Schools
w3schools.com › c › c_pointers.php
C Pointers
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java and XML.
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!

🌐
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
🌐
Launch School
launchschool.com › books › python › read › variables_pointers
How Python objects and variables really work
Thus, when you access a variable, Python first determines where the variable is on the stack. It then takes the object's heap address from the stack item and uses it to find the object. The variable is a pointer to a stack location, and the stack location is a pointer to the object. Let's break that down with an example. Assume we're creating a variable named numbers and giving it an initial value of a list with 3 numbers:
🌐
W3spoint
w3spoint.com › pointer-in-python
W3spoint
Free Online Tutorials, W3schools provides tutorials and interview questions of all technology like java, android, physics, chemistry, math, english, javascript, ajax, core java, sql, python, php, c language etc.
🌐
GeeksforGeeks
geeksforgeeks.org › python › using-pointers-in-python-using-ctypes
Using Pointers in Python using ctypes - GeeksforGeeks
July 23, 2025 - As the name suggests void pointer is a type of Pointer that has no specific data type associated with it. It can be typecasted into any type and can hold data of any type. 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.
🌐
Europython
ep2024.europython.eu › session › pointers-in-python
Pointers in Python
July 8, 2024 - 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.
Find elsewhere
🌐
W3Schools
w3schools.com › c › index.php › c_pointers.php
W3Schools.com
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
🌐
Pyvideo
pyvideo.org › pycon-us-2024 › pointers-in-python.html
PyVideo.org · Pointers in Python
May 16, 2024 - 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.
🌐
W3Schools
w3schools.com › c › c_structs_pointers.php
C Structs and Pointers
Tip: If you're working with big ... struct pointers can help make your code cleaner and more efficient. ... Coding fundamentals as bite-sized lessons and challenges. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS ...
🌐
LearnXbyExample
learnxbyexample.com › learn x by example › python programming › pointers in python
Pointers in Python | Learn X By Example
September 21, 2024 - The id function returns a unique identifier for an object, which remains constant for the life of the object. This is the closest equivalent in Python to a memory address in languages with explicit pointers.
🌐
Sanshaacademy
sanshaacademy.com › python › advance › pointers.php
Python Pointers
1: Introduction to DS 2: Abstract ... Binary Tree 16: Binary Search Tree 17: AVL Tree 18: Tree Traversals 19: Heap 20: Graph ... Python does not support explicit pointers like C or C++. However, variables in Python store references to objects, not the actual data....
🌐
Python Morsels
pythonmorsels.com › variables-are-pointers
Variables are pointers in Python - Python Morsels
July 18, 2026 - An assignment in Python points a variable to an object. That's it! Variables don't contain objects, and nothing gets implicitly copied during an assignment. Instead of thinking of variables as buckets that contain objects, think of them as bindings, ...
🌐
Anvil
anvil.works › articles › pointers-in-my-python-1
Memory Management in Python - Part 1: What Are Pointers?
So, when you create a list, it will automatically contain pointers if it has any elements. For that reason, we’ll be using a lot of lists as examples throughout this article. ... One Python behaviour that often trips up a lot of beginners is something called pointer aliasing, which is when two pointers refer to the same object in memory.
🌐
Scaler
scaler.com › home › topics › do we have pointers in python?
Do We Have Pointers in Python? - Scaler Topics
May 4, 2023 - It manages the code very well. It may be difficult for beginners, but it is an important concept in the program. However, it can result in a variety of memory management bugs. Python does not have explicit pointers like other languages, although they are implemented beneath the hood.
🌐
Quora
quora.com › How-do-you-work-with-pointers-in-Python
How to work with pointers in Python - Quora
Answer (1 of 6): You can’t work with a arbitrary pointer into memory (as you can in C or C++; there isn’t the equivalent of malloc or realloc. Having said that when you do something like [code]a = 3 [/code]The name a is now associated with a reference (a smart pointer) to an integer object, ...
🌐
GitHub
github.com › ZeroIntensity › pointers.py
GitHub - ZeroIntensity/pointers.py: Bringing the hell of pointers to Python. · GitHub
from pointers import _ text: str = "hello world" ptr = _&text # creates a new pointer object ptr <<= "world hello" print(text) # world hello
Starred by 934 users
Forked by 11 users
Languages: Python 98.4% | C 1.6%