Comment

Comment by tacostakohashi

The problem I have with Python is that for loops don't have their own scope, only methods.

Add that to the lack of variable declarations (even optional ones, a la my in perl, var in javascript), and it gets hard to work out what scope of any given variable actually is.

Surprising example:

  fns = []

  for n in [1,2,3,4]:
    def fn():
      print(n)
    fns.append(fn)

  for fn in fns:
    fn()

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton