Comment

Comment by softwaredoug

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 "<stdin>", line 1, in <module>
  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

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton