AI engineering glossary · Python core

What is pass by object reference?

Pass by object reference (also called call by sharing): Python's argument-passing model: a function receives a reference to the same object the caller has. Mutating a mutable argument inside the function is visible outside, but rebinding the parameter name is not.

Level: advancedTopic: Python core

Pass by object reference: an example

def f(lst): lst.append(1) changes the caller's list, while lst = [] inside f does not.

Related terms

More Python core terms

Where you learn it

Pass by object reference is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.