I'll be that person

I asked ChatGPT:

> Gary Berhnhardt gave a famous talk called "Wat" about Javascript. Can you create similar "Wat" style examples for Python?

The examples it gave me were... not that 'wat'-y

Sure, here are some "Wat"-style examples for Python:

1. Unpacking tuples:

  >>> a, b = (1, 2)
  >>> a
  1
  >>> b
  2

  >>> a, b = 1, 2
  >>> a
  1
  >>> b
  2

2. Division by zero:

  >>> 1 / 0
  Traceback (most recent call last):
    File "", line 1, in 
  ZeroDivisionError: division by zero

Though this one is interesting:

4. Using the is operator:

  >>> x = 256
  >>> y = 256
  >>> x is y
  True

  >>> x = 257
  >>> y = 257
  >>> x is y
  False
See https://github.com/satwikkansal/wtfpython

"Mutating the immutable" is my personal favourite - the second line of code fails with an exception despite having already succeeded:

    >>> t = ([1, 2], 5, 6)

    >>> t[0] += [3, 4]
    TypeError: 'tuple' object does not support item assignment

    >>> print(t)
    ([1, 2, 3, 4], 5, 6)
I've never been a fan of the decision to have `a += b` sometimes do `a = a + b` and sometimes update `a` in place. My objection was initially just due to theoretical inelegance - but this code shows that decision directly causing a concrete problem.