user
Why Alice is always in the Python examples?
alphonsio

Alice is commonly used in Python examples (and programming in general) because she comes from the classic cryptography and communication examples, where Alice and Bob are used to represent two parties exchanging messages.


Illustration of Alice and Bob in cryptography

This convention originated in a 1978 paper "A Method for Obtaining Digital Signatures and Public-key Cryptosystems" on public-key cryptography by Ron Rivest, Adi Shamir, and Leonard Adleman (the inventors of RSA encryption).

In Python examples, Alice often appears because:

  1. Familiarity – Many programmers recognize Alice and Bob as placeholder names for people in coding examples.
  2. Readability – Using real-sounding names (Alice, Bob) makes it easier to understand than generic variables like user1 or personA.
  3. Tradition – Many programming books and tutorials continue the convention, especially in Python, which values clarity and simplicity.

You'll often see:

  • Alice and Bob sending messages in cryptography examples.
  • Alice and Bob in object-oriented programming (OOP) to represent users interacting with a system.
  • Alice buying items in Python finance or e-commerce examples.

Sometimes Charlie, Eve, and Mallory join the mix—especially when discussing adversaries in security contexts.