logoalt Hacker News

frollogastontoday at 12:54 AM1 replyview on HN

A lot of those are stuff I'd never do like `Test.prototype = null;`. Some are legit footguns, but they rarely get in your way.

Python has weird file imports (no relative ones either), broken package management, historical differences between asyncio and blocking that still cause issues, threading/GIL caveats that trip up even experienced users, indentation for scope (esp weird given it was designed for REPL), weirdly no anonymous functions, 2 vs 3 (mostly gone by now), the __init__ and __init__.py stuff, namedtuple vs dict vs object, `global`, and a whole mess with type-linting if you're going there. You have to deal with all those things every time.

Here's one little Python footgun that everyone hits and is also annoying after:

  def func(array=[]):  # default value is empty array, right?
      array.append("asdf")
      print(array)

  >>> func()
  ['asdf']
  >>> func()
  ['asdf', 'asdf']

Replies

Daishimantoday at 2:39 AM

What you put as an example isn't a footgun if you know how the language evaluation rules work. Once you understand that the "footgun" explains a dozen behaviors, which may be a weird behavior but it is consistent.

show 1 reply