Paying attention with Python

Nicholas H.Tollervey

ntoll@ntoll.org

Data science FTW, baby!

  • Orangutan 🦧
    • Free bananas 🍌
    • Zero work hours 👌
    • No training necessary ✅
  • Classical musician 🎶
    • Low pay 📉
    • Late night work 🌙
    • Years of intense practice 😓

Asking what sort of education we want is the same as asking what sort of community we want to become.

For education is the process through which we interact with our future colleagues, collaborators and friends.

Software

(For beginner coders)

💬 🧄 🇫🇷 🥐 🎉

😬

By paying attention to Mu in a certain way, we're demonstrating a certain coding culture.

Mu is also the means of passing on such a culture.

That culture is open, collaborative and supportive,

...and so is Mu.

Paying attention

The danger is we are...

  • Finding problems that don't exist
  • Creating thoughtless solutions
  • Writing complicated code
  • Measuring success in dubious ways
  • Following shallow "best practices"

Problems that don't exist 🔍

Thoughtless solutions 🧟

The fundamental design flaws are completely hidden by the superficial design flaws.

Complicated (crap) code 💩


          print("Hello, world!")  # Beginner 👶
          

          def hello(name="world!"):  # Junior coder 🧑‍🎓
            return f"Hello, {name}"

          print(hello())
          

          class Hello:  # Enterprise programmer 👔

            def __init__(self, name="world!"):
              self.name = name

            @property
            def greet(self):
              return f"{self.__class__.__name__} {name}"
          
          print(Hello().greet)
          

          print("Hello, world!")  # Experienced engineer 👷
          

          # YAGNI ;-) a virtuoso coder 🤦
          

Measuring success? 📈

"Best practices" 🤣😱😭

🐔

chicken.py?


"""
Chicken chicken chicken chicken chicken chicken chicken.

Chicken (c) 2021 Nicholas H.Tollervey.

Chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken. Chicken chicken chicken chicken chicken chicken chicken
chicken. Chicken, chicken chicken chicken, chicken chicken, chic-
ken chicken chicken “chicken chicken” chicken “chicken chicken”
chicken.

Chicken chicken chicken chicken chicken. Chicken-chicken chic-
ken chicken chicken chicken chicken chicken, chicken chicken chi-
cken chicken, chicken, chicken chicken chicken “chicken” chicken.

CHICKEN, CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHI-
CKEN (CHICKEN CHICKEN) CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN,
CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN
CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN. cHICKEN CHICKEN CHICKEN
CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN, CHICKEN CHICKEN
CHICKEN, CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN.
"""
import sys as chk
from builtins import print as chicken
from builtins import range as freerange
from random import choice as Chicken


EGG = 0
CHICKEN = 1

#: Chicken.
__CHICKEN__ = f"{CHICKEN}.{EGG}.{CHICKEN}"


#: Chicken chicken CHICKEN "chicken"
_CHICKEN = [
    "CHICKEN",
    "chicken",
    "Chicken",
    "chicken",
    "'Chicken'",
    "chicken",
    "Chicken-chicken",
    "chicken",
    '"Chicken"',
    "chicken",
    "(Chicken)",
    "chicken",
]


def chckn():
    """
    Chicken chicken chicken chicken. Chicken _CHICKEN chicken chicken.

    Chicken: chicken.
    """
    return Chicken(_CHICKEN)


def _chckn(chickens=EGG):
    """
    Chicken chicken chicken CHICKEN Chicken-chicken.

    chickens: Chicken chicken 'Chicken' chicken. (Chicken: EGG)

    >>> assert _chckn() == CHICKEN
    >>> assert _chckn(CHICKEN) == CHICKEN + CHICKEN
    >>> assert _chckn() + _chckn() == _chckn(_chckn())
    """
    # CHICKEN: Chicken chicken (Chicken) Chicken-chicken "Chicken" (#2)
    return chickens + CHICKEN


def _chicken(argchicken=f"{CHICKEN}{EGG}"):
    """
    Chicken chicken chicken chicken chicken 'chicken'.

    Chicken chicken, chicken chicken chicken chicken:

    * Chicken chicken.
    * Chicken CHICKEN chicken.
    * Chicken-chicken CHICKEN.

    (Chicken chicken chicken chicken?)
    """
    if chk.argv[CHICKEN:]:
        # Chicken chicken.
        argchicken = chk.argv[CHICKEN]
    try:
        # Chicken :-)
        eggs = int(argchicken) - CHICKEN
    except (TypeError, ValueError):
        # Chicken :-(
        eggs = _chckn(
            _chckn(_chckn(_chckn(_chckn(_chckn(_chckn(_chckn(_chckn())))))))
        )
    # Chickens!
    chicken(
        "Chicken " + " ".join([chckn() for chick in freerange(eggs)]) + "."
    )


if __name__ == "__main__":
    _chicken(chk.argv[CHICKEN:])
          

🚫🐔🚫

Chicken

The Secret:

STUDENT: O Guru, what is the secret of success?

GURU: Good judgement.

STUDENT: How do you get good judgement?

GURU: Experience.

STUDENT: How do you get experience?

GURU: Bad judgement!

To what we pay attention is important. How we pay attention is equally consequential but often unconscious. Considering why we pay attention is perhaps most significant ~ an engaging, poignant and sadly neglected opportunity for self-examination.

Thank you

Questions & Debate

</rant>

🤗 🇵🇹 🐍