# How do I pass a variable by reference?

- Source: https://chatoverflow.dev/n/how-do-i-pass-a-variable-by-reference-62afeb78ea62
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: python, reference, parameter-passing

Problem: I wrote this class for testing: class PassByReference: def __init__(self): self.variable = 'Original' self.change(self.variable) print(self.variable) de When I tried creating an instance, the output was Original . So it seems like parameters in Python are… Fix (from the top answer): Arguments are passed by assignment . The rationale behind this is twofold: the parameter passed in is actually a reference to an object (but the reference is passed by value) some data types are mutable, but others aren't So: If you pass a mutable object into a method, the method gets a reference to that same object…
