Skip to main content

Python object model

Python Variables: Names, Objects, Scope, and Identity

Python variables are names bound to objects. This model explains assignment, shared mutation, identity, function arguments, and scope more accurately than a box metaphor.

Pythonbeginner4 min readPython fundamentals

Learning overview

Estimated time
4 minutes
Difficulty
Beginner
Prerequisites
No prior experience required
Learning outcome
Explain python using a clear mental model · Apply python in practical Python work
Last updated
July 18, 2026

Assignment binds names to objects

Assignment does not copy an object. Two names can refer to the same mutable list, so a mutation through either name is visible through both. Rebinding one name does not change the other.

bindings.py
primary = ["Python"]
alias = primary
alias.append("SQL")
assert primary == ["Python", "SQL"]

alias = ["Java"]
assert primary == ["Python", "SQL"]

Separate identity from equality

The == operator asks whether values compare equal. The is operator asks whether two references identify the same object. Use is for singletons such as None, not for strings or numbers.

Follow lexical scope

Python resolves names through local, enclosing, global, and built-in scopes. Avoid global mutable state; pass values into functions and return results. Use nonlocal or global only when the shared binding is deliberate and documented.

Frequently asked questions

Does Python have variables without types?

Names are not fixed to one type, but every object has a type. A name can be rebound to a different object unless a tool-enforced contract prevents it.

When should I use is in Python?

Use it for object identity, most commonly value is None or value is not None. Use == for value comparison.

Topic graph

A taxonomy-generated path through this subject.

  1. Python
  2. Python fundamentals
  3. python
  4. variables
  5. scope
  6. object-model
  7. What Is Python in Programming?
  8. Learn Python: From Fundamentals to Real Applications
  9. Python Tutorial: Build a Command-Line Expense Tracker

Recommended automatically from shared technologies, topics, intent, and difficulty.

Hand-picked companion pages that deepen this topic.

Your next steps

Continue learning

  1. 1glossaryWhat Is Python in Programming?
  2. 2guidesLearn Python: From Fundamentals to Real Applications
  3. 3guidesPython Tutorial: Build a Command-Line Expense Tracker
  4. 4cheatsheetsPython Cheatsheet: Syntax, Collections, Files, and OOP