News for hackers. Stuff that matters.
Re:The worst thing about CoffeeScript by gvalkov on Saturday January 25, 2014 @12:56PM (#7121556)
By using Python3's nonlocal statement.

  def outer():
      a, b = 1, 2

      def inner():
          nonlocal a
          a, b = 3, 4
          print('inner a: ', a)
          print('inner b: ', b)

      inner()
      print('outer a: ', a)
      print('outer b: ', b)

  outer()
  # inner a:  3
  # inner b:  4
  # outer a:  3
  # outer b:  2
I find Python's scoping rules to be quite sane.

There are no comments on this comment yet.