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 ...
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!

Discussions

Why doesn't Python have pointers?
What’s a pointer More on reddit.com
🌐 r/learnpython
63
128
April 21, 2023
Question: Why are NULL pointers so ridiculously hated?
Looking at it the other way around, what advantage does the use of null provide over an option/result type? More on reddit.com
🌐 r/ProgrammingLanguages
90
0
May 25, 2023
[Help] What does it mean when a function parameter is a pointer to a data type?
I recommend going through this from the beginning: https://go.dev/tour/list Otherwise the very beginning of this one has some info about pointers: https://go.dev/tour/moretypes/1 And here about methods and receivers which should help you understand why pointer receivers are used and when to use them: https://go.dev/tour/methods/1 More on reddit.com
🌐 r/golang
9
1
March 5, 2023
Can someone properly explain the relevance of double pointers to me in linked lists? I'm a little confused
Let's look at this from the caller's perspective. Assume I have the following. node_t *head = create_node(...); If I want to insert a node at the front of the list, that new node needs to become the head (head means the first node in the list). Your first function doesn't change the head, and in fact has no way to do so. You can't do this, for example node_t *insert_at_head(node_t *head, node_t *node_to_insert){ node_to_insert->next = head; head = node_to_insert; // this line is useless return node_to_insert; } void foo() { node_t *head = create_node(...); insert_at_head(head, create_node(...)); // head now points to the second node ... } Because the head inside the function is a copy of the caller's head, the assignment inside the function has no visible effect to the caller. With the second version, you can do this: node_t *insert_at_head(node_t **head, node_t *node_to_insert){ node_to_insert->next = *head; *head = node_to_insert; return node_to_insert; } void bar() { node_t *head = create_node(...); insert_at_head(&head, create_node(...)); // note the & in front of head // head has been modified, and points to the newly added node ... } Note that the first version is not necessarily wrong, it just requires manual upkeep of the head pointer on the caller's end. In fact, that's probably why it returns a value, so you can do that upkeep seamlessly, like so: void baz() { node_t *head = create_node(...); head = insert_at_head(head, create_node(...)); } With the double pointer version, you can't accidentally forget to update the value of head though. More on reddit.com
🌐 r/C_Programming
21
8
May 3, 2024
🌐
Anvil
anvil.works › articles › pointers-in-my-python-1
Memory Management in Python - Part 1: What Are Pointers?
Pointers can be thought of as names - that is, entries in Python’s namespace - that correspond to objects in Python’s memory. In the above example, the pointer is my_string, and the object in memory is the string with value "Hello World!". By using a pointer in namespace, you can access and manipulate the object in memory. And, just as a person might have multiple names, multiple pointers might point to the same object. A note about terminology: the ‘pointers’ referred to in this article are not directly equivalent to pointers in C or C++ (in fact, they’re more similar to references in C++).
🌐
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
🌐
Pencil Programmer
pencilprogrammer.com › home › python tutorials › pointers in python (explained with examples)
Pointers in Python (Explained with Examples) | Pencil Programmer
December 17, 2025 - Pointers in the context of high-level languages like C++ or Java are nothing but variables that stores the memory address of other variables or objects. We can reference another variable stored in a different memory location using a pointer ...
🌐
Reddit
reddit.com › r/learnpython › why doesn't python have pointers?
r/learnpython on Reddit: Why doesn't Python have pointers?
April 21, 2023 -

No, really. I've just started practicing problems on Leetcode and today I tried to do a bunch of things with Linked lists in python. I always second guess myself when I'm writing assignment statements like node = next_node because I'm worried that using shallow copies might screw things up for me.

Wouldn't it have been way easier to directly reference objects by their memory location?

I'm not going to use C for coding interviews so I'd also appreciate any ways I can idiot proof my code when I'm dealing with moving and assigning objects in Python.

One idea I had was to include a deepcopy method in the List node class definition but I can't make any changes to the leetcode question setup.

Top answer
1 of 28
219
Because it’s high level by design
2 of 28
137
Pointers are a concept that really doesn't make sense in Python, both because of practical reasons and philisophical reasons. In Python, "variables" are really "lebels" attached to objects, not a specific memory location in your address space. The internals of the Python interpreter do make use of pointers, but that's because it's written in C. Philisophically, the designers of Python view pointers as an intrinsically bad thing - they have all sorts of downsides that would have made Python a bad language. What Python has instead, is bindings - the labels I mentioned above - and they actually do behave in some ways like pointers, but without the downsides. Bindings do not have a type, but the objects they are bound to do have a type, and unlike in C, an object (i.e. a value or more complex type) can have multiple labels. Furthermore, container types like tuples, lists, and dictionaries contain references to objects, which are very like pointers: they don't have a name (binding) but they do give you a way to refer to an object - of any type. If you make a linked list element class in Python like this: class Element: def __init__(self,pred,value): self.pred = pred self.value = value That gives you a linked list with a reference to the previous Element in each object, and you can traverse the links like this: >>> a = Element(None,1) >>> b = Element(a,2) >>> c = Element(b,3) >>> c.pred.pred.value 1 >>> c.pred.value 2 Semantically, that's pretty much like pointers. Generally it's less useful to use such structures in Python, though it's still valid in some situations, but you can take advantage of references to build complex dynamic data structures you can traverse in the same way as most linked-list or tree structures in other languages.
🌐
Scaler
scaler.com › home › topics › do we have pointers in python?
Do We Have Pointers in Python? - Scaler Topics
May 4, 2023 - In the context of high-level languages such as C++ or Java, pointers are simply variables that store the memory address of other variables or objects. It manages the code very well. It may be difficult for beginners, but it is an important concept in the program.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › article › what-is-the-pointer-in-python-does-a-pointer-exist-in-python
What is the Pointer in Python? Does a Pointer Exist in Python?
April 4, 2023 - When you define a variable in Python, you are creating a reference to an object. This reference essentially serves as a pointer to the location in memory where the object is stored.
🌐
Ned Batchelder
nedbatchelder.com › blog › 202403 › does_python_have_pointers
Does Python have pointers? | Ned Batchelder
March 11, 2024 - So Python doesn’t have the classic pair of operations to be able to work with pointers explicitly. But on the other hand, every variable in Python is a pointer, because variables in Python are names that refer to objects.
🌐
Medium
medium.com › @abhishekjainindore24 › the-concept-of-pointers-in-c-and-c-and-why-python-doesnt-have-them-9ade1875d9ed
The Concept of Pointers in C and C++ and Why Python Doesn’t Have Them | by Abhishek Jain | Medium
October 14, 2024 - Pointers are variables that hold the memory address of another variable. This concept is important for understanding how memory is managed, optimized, and manipulated at a low level.
🌐
Launch School
launchschool.com › books › python › read › variables_pointers
How Python objects and variables really work
The behaviors described in this chapter arise from the interaction of variables using pointers to reference their associated objects. In Python, all variables are pointers to objects. If you assign the same object to multiple variables, every one of those variables references (points to) the ...
🌐
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.
🌐
Real Python
realpython.com › videos › pointers-python-overview
Pointers and Objects in Python (Overview) (Video) – Real Python
Pointers are essentially variables that hold the memory address of another variable. They allow you to create great efficiency in parts of your code but can lead to various memory management bugs.
Published: July 7, 2020
🌐
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. We are just typecasting it like C/C++ early.
🌐
Quora
quora.com › What-is-the-pointer-in-Python-Does-a-pointer-exist-in-Python
What is the pointer in Python? Does a pointer exist in Python? - Quora
Answer (1 of 7): Answer to: “What is the pointer in Python” Background: I come from assembly language and games coding in C++, so I know what pointers are all about. It’s important to understand variables in Python are effectively pointers in practical use. The equal “=” assignment ...
🌐
Medium
sushantpupneja.medium.com › python-pointers-revealed-f04a1ba30835
Python Pointers - revealed. What are Pointers? | by Sushant Pupneja | Medium
February 28, 2021 - Pointers are widely used in C and C++. Essentially, they are variables that hold the memory address of another variable. Lets understand pointers with simple real world analogy. ... Pointers seem to go against the Zen of Python.
🌐
Python Morsels
pythonmorsels.com › variables-are-pointers
Variables are pointers in Python - Python Morsels
July 18, 2026 - Variables in Python are not buckets that contain things, but pointers: variables point to objects.
🌐
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.
🌐
Quora
quora.com › What-are-pointers-in-Python-Is-it-possible
What are pointers in Python? Is it possible? - Quora
Answer (1 of 3): Pure python does not have the concept of pointers but that of objects or instances. This is mainly because applications python was originally designed for did not require direct access to memory. Plus it would be not a particularly nice tool to allow programmers to use given Pyth...