Skip to content

Breaking Bad's Lessons for Python Developers: Ethics, Best Practices, and Avoiding Disaster

Published: at 06:26 AM

Breaking Bad

The Emmy award-winning television series Breaking Bad fascinated audiences with its story of Walter White, a high school chemistry teacher turned methamphetamine kingpin. While fictional, the show imparts several valuable lessons applicable to legitimate fields like software development. As Python developers and engineers, examining Breaking Bad’s themes can provide guidance on best practices, ethics, and personal conduct. In this article, we will explore five key lessons that Breaking Bad teaches about pride, trust, consequences, morality, and power, along with their implications for Python programmers.

Note: The code examples and scenarios presented in this article are fictional and intended for illustrative purposes only.

Don’t Let Pride Override Quality

As a teacher, Walter White took pride in imparting knowledge and empowering his students. When cancer threatened to cut his career short, that same pride drove him to find illegal ways to provide for his family. He insisted on cooking extremely pure meth himself rather than accepting help from his former student Jesse Pinkman:

# Fictional example modeling Walter's thought process

# Import fictional chemistry utility module
import fictional_chemutils

# List of chemicals in Walter's formula
walter_formula = [
    "Phenylacetic acid",
    "Red phosphorus",
    "Ethyl Ether"

# List of chemicals in Jesse's formula
jesse_formula = [
    "Red phosphorus",
    "Ethyl Ether",

# Calculate purity percentages
# Using fictional calculate_purity function
walter_purity = fictional_chemutils.calculate_purity(walter_formula)
jesse_purity = fictional_chemutils.calculate_purity(jesse_formula)

# Print results
print(f"Walter's purity: {walter_purity}%")
print(f"Jesse's purity: {jesse_purity}%")

This fictional example mirrors how Walter’s pride led him to take dangerous risks rather than produce a slightly less pure product with help. As Python developers, we must balance pride in our work with pragmatic concerns - perfectionism can be costly. Rushing to implement an elegant machine learning model without proper testing, for example, could cause major bugs. Collaborating with others doesn’t make you any less of an expert.

Vet Partners Carefully

Walter made the mistake of partnering with untrustworthy people, including his former student Jesse Pinkman. Jesse’s recklessness and drug addiction caused Walter much grief:

# Fictional example of partner background check

# Import fictional background check module
from fictional_backgroundcheck import verify_background

# Partner 1 data
walter = {"name": "Walter White",
           "qualifications": ["PhD Chemist"],
           "criminal_history": False}

# Partner 2 data
jesse = {"name": "Jesse Pinkman",
         "qualifications": ["High School Chemistry"],
         "criminal_history": True}

# Perform fictional background checks
walter_check = verify_background(walter)
jesse_check = verify_background(jesse)

# Print results
print(f"{walter['name']} background check: {walter_check}")
print(f"{jesse['name']} background check: {jesse_check}")

While fictional, this illustrates the importance of vetting partners thoroughly. Real-world methods like code reviews, background checks, and professional reference checks can prevent issues when collaborating.

Actions Have Consequences

Walter rationalized his meth cooking as being victimless, but it had devastating consequences for his family and community. The ripple effects of his moral compromise cost lives:

# Fictional ethics analysis module
import fictional_ethics

# Test cases of actions with intents
actions = [
  {"action": "cooking meth", "intent": "provide for family"},
  {"action": "killing rivals", "intent": "self-defense"},
  {"action": "bribery", "intent": "avoid jail time"}

# Evaluate ethicality of each action
for act in actions:

  # Call fictional ethics evaluation function
  consequence = fictional_ethics.evaluate(act)

  if consequence == "moral":
    print(f"{act['action'].title()} was ethical given {act['intent']}")
    print(f"{act['action'].title()} was unethical despite {act['intent']}")

While fictional, this shows how even actions taken with good intent can be unethical. As Python developers, we must consider potential real-world consequences - seemingly harmless technical choices could enable abuse according to frameworks like the ACM Code of Ethics.

Don’t Let Ego Override Ethics

Walter White’s ego and pride led him to abandon his principles for self-gain. The fictional scenario mirrors how applying his skills to criminal enterprise fed Walter’s ego while destroying lives:

# Fictional ethics checking module
import fictional_ethics

# Function to check action against ethical values
def check_ethics(action, values):

  for value in values:

    # Call fictional ethics evaluation function
    if fictional_ethics.evaluate(action, value) == False:
      return False

  return True

# Example ethical values
my_values = ["help others", "cause no harm", "obey the law"]

# Test cases
action1 = "cooking meth"
action2 = "teaching chemistry"

print(check_ethics(action1, my_values)) # False
print(check_ethics(action2, my_values)) # True

This fictional check_ethics function highlights the need to evaluate our work against a moral code. In the real world, Python developers should routinely check alignment with ethical values, even if technical abilities enable morally dubious applications.

Power Corrupts

As Walt accumulated wealth and notoriety in the fictional drug trade, he became increasingly corrupt, hurting even those closest to him:

# Class to model corrupting power

class Person:

  def __init__(self, name, morality=100):

    # Initialize attributes = name
    self.morality = morality

  def gain_power(self, power_gained):

    # Decrease morality as power increases
    self.morality -= 0.5 * power_gained

# Create instance
walt = Person("Walter White")

# Gain power

# Print result
print(f"{}'s morality: {walt.morality}")

This fictional example models decreasing morality as power increases, reflecting Walter White’s transformation. While difficult situations may warrant exceptions, as Python developers we must guard against incremental ethical compromises over time. It’s a slippery slope.


While fictional, Breaking Bad provides stark warnings about rationalization and ethical compromises. As Python developers, we have considerable power to do both harm and good through our code. Pressures may push us to cut corners, but a strong moral compass can keep us on the ethical path - as promoted by frameworks like the ACM Code of Ethics. By learning from the mistakes of characters like Walter White, we can write code that helps others and does no harm.

Here are some suggested best practices for keeping ethics central to our Python development:

The field of ethical AI presents many opportunities for Python developers to contribute their skills towards the greater good. By taking responsibility for the consequences of our code, we can help foster positive change.