Brains Are Beautiful Liars

“Preferential Looking”

“Violation of Expectations”

Flawlessly

Flawfully

Falafely

Fluffily

Words Matter

© 2024 Akiyoshi Kitaoka, used with permission

https://www.psy.ritsumei.ac.jp/akitaoka/saishin72e.html

#7c7c7c

https://www.psy.ritsumei.ac.jp/akitaoka/saishin72e.html

Metacognition

Thinking About Thinking

Metacognition

I am a learner, a dabbler, and a hobbyist

Python teacher and PSF CoC WG alumnus

Thinking about teaching, learning,
language, intent, and perception

Cognitive Biases

Mental Models

Making Progress


>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
          

Start

Answers

Questions

Patterns are great

Shortcuts are great

Heuristics are great

“I've come this far. I can't give up now.”

Sunk Cost Bias

Cognitive Biases

Amos Tversky & Daniel Kahneman

Thinking Fast and Slow

By Daniel Kahneman

System 1

(Fast Thinking)

System 2

(Slow Thinking)

Sunk Cost Bias

“I've come this far. I can't give up now.”

Bandwagon Effect

bandwagon.js

Confirmation Bias

Validating your current assumptions

February 29, 1968

βœ…

πŸ§ͺ

😞

Quality Assurance

πŸ‘©

πŸ‘©β€πŸŽ€

Large image top-left
Small image right-middle
Small image left-bottom

Anchoring Bias

Anchoring Bias

“Can you get this done in 13 weeks?”

“Yes. This should take about 8 weeks.”

“I expect this to take 1 week. What do you think?”

“No way. More like 4 weeks.”

Status Quo Bias

Default State

Action Bias

Chesterton's Fence

“This code is too complex”

“This shouldn't be necessary”


def dedent(text):  # Python's textwrap.dedent (most of it)
    margin = None
    text = _whitespace_only_re.sub('', text)
    indents = _leading_whitespace_re.findall(text)
    for indent in indents:
        if margin is None:
            margin = indent
        elif indent.startswith(margin):
            pass
        elif margin.startswith(indent):
            margin = indent
        else:
            for i, (x, y) in enumerate(zip(margin, indent)):
                if x != y:
                    margin = margin[:i]
                    break
    if margin:
        text = re.sub(r'(?m)^' + margin, '', text)
    return text
          

Overconfidence Effect

Dunning-Kruger Effect

Get a team to check your abilities

Not Invented Here

(Ingroup bias)

outside code? πŸ‘Ž

our code πŸ‘

Have a problem?

Write code!

πŸ—οΈ πŸ”¨

JSON data

import json

simplejson

Do It Yourself

Not Thought of By Me

Ask a coworker for help πŸ’–

Use a search engine πŸ”

Ask Chat GPT, Claude, etc. πŸ€–

Don't Build it Yourself

Ask for Help

I use a search engine ~500 times/mo

I start ~2 new LLM chats per day

Recognize Your Biases

Bias Blind Spot

Ack a bug in my video!

Should I edit it?

Or should I re-record?


>>> x = []
>>> x.append(x)
>>> x
[[...]]
>>> x in x
True
>>> x[0] is x
True
>>> [[...]]
[[Ellipsis]]
          

>>> x = []
>>> x.append(x)
>>> x
[[...]]
>>> x in x
True
>>> x[0] is x
True
>>> [[...]]
[[Ellipsis]]
          

>>> x = []
>>> x.append(x)
>>> x
[[...]]
>>> x in x
True
>>> x[0] is x
True
>>> [[...]]
[[Ellipsis]]
          

#PythonOddity

Quirks within our mental model of Python

github.com/treyhunner/python-oddities

Mental Models


>>> first = []
>>> second = first
>>> first.append(9)
>>> first
[9]
>>> second
[9]

Buckets


>>> first = []
>>> second = first
>>> first.append(9)
>>> first
[9]
>>> second
[9]
first [9] second [9]

This mental model breaks down

Sticky Notes


>>> first = []
>>> second = first
>>> first.append(9)
>>> first
[9]
>>> second
[9]
>>> 
            
[9] first second

Sticky Notes


>>> first = []
>>> second = first
>>> first.append(9)
>>> first
[9]
>>> second
[9]
>>> rows = [first]
>>> lists = rows
[9] first second rows[0] lists[0]

Pointers


>>> first = []
>>> second = first
>>> first.append(9)
>>> first
[9]
>>> second
[9]
>>> rows = [first]
>>> 
            
Object Land Variable Land list first second int 9 0 rows list 0

Pointers


>>> first = []
>>> second = first
>>> first.append(9)
>>> first
[9]
>>> second
[9]
>>> rows = [first]
>>> 
            
Object Land Variable Land list first second int 9 0 rows list 0

Linguistic Determinism

Linguistic Relativism

“when I change first, it doesn't always change second


>>> first = [2, 1, 3, 4]
>>> second = first
>>> first.append(7)
>>> second
[2, 1, 3, 4, 7]
>>> first = [100, 200, 300]
>>> second
[2, 1, 3, 4, 7]
>>> 
          

“bianually”

twice a year or once every two years

“4 ounces”

a half cup or a quarter pound

“change”

assigning a variable or mutating a value

“when I mutate the list, both first and second change”

“when I reassign first, it doesn't affect second

“when I change first, it doesn't always change second


>>> first = [2, 1, 3, 4]
>>> second = first
>>> first.append(7)
>>> second
[2, 1, 3, 4, 7]
>>> first = [100, 200, 300]
>>> second
[2, 1, 3, 4, 7]
>>>
          

“Explicit is better than implicit”


>>> first = [2, 1, 3, 4]
>>> second = first
>>> first.append(7)
>>> second
[2, 1, 3, 4, 7]
>>> first = [100, 200, 300]
>>> second
[2, 1, 3, 4, 7]
>>>
            
Object Land Variable Land list second first [2, 1, 3, 4] [2, 1, 3, 4, 7] list [100, 200, 300]

>>> colors = ["purple", "green", "blue"]
          
  • ❌colors contains a list of strings”
  • ⚠️colors is a list of strings”
  • βœ…colors points to a list of strings”

➑️

Word Choice Matters

β€œAll models are wrong,
but some models are useful.” — George E. P. Box

Economics

Immigration

Education

β€œAll models are wrong,
but some models are useful.” — George E. P. Box
β€œEach model is more useful for some purposes than others” — me

Iterating


>>> for item in some_iterable:
...     do_something_with(item)
...
          

Progress

The Python Software Foundation

2001: PSF was founded

2013: PSF adopts a Code of Conduct πŸ˜…

2016: PSF notes email for reports πŸ˜…

2017: PSF forms a CoC workgroup πŸ˜…

2019: PSF adopts new Code of Conduct

β€œThe world can be both bad and better.”
— Hans Rosling in Factfulness

Blocked Versus Interleaved Practice

“Now I must update all my curriculum”

The Options

  1. Immediately fix the problem
  2. Deny that there's a problem
  3. Appreciate the status quo while noting the problem
β€œMy abilities can be both improving and have room for improvement”
β€œA scenario can be both okay and unideal”

Problem Solving Steps

  1. Understand the problem
  2. Break down the problem

    What's the MVP?

  • Oct 2017: beta testing starts
  • Feb 2018: paid email list launched
  • Sept 2018: web app launched
  • Mar 2019: web app grades exercises
  • Apr 2021: choose your own pace

Perfect is the
enemy of good

enemy of progress

Small steps add up over time

Slow Path to Change

I may not be where I imagine,
but I am making progress.

β€œThe world can be both bad and better.”
— Hans Rosling in Factfulness

Growth Mindset

Domain-Specific Mindsets

How much have you changed over the past 10 years?

preferences, personality, goals, core values

How much have you changed over the past 10 years?

preferences, personality, goals, core values

How much will you change over the next 10 years?

preferences, personality, goals, core values

“The Only Lasting Truth Is Change”

—β€ŠOctavia E. Butler Parable of the Sower

Resources   trey.io/pyohio2024

How will you notice your biases?
What mental models do you have?
What progress might you make?

Trey Hunner
Python Team Trainer
[email protected]