Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Python (before version 3) leaks variables from list comprehension, while it seems natural to assume that the comprehension has its own scope. Makes for some funny bugs:

  i = ...
  ... # lots of code 
  [ do_stuff(i) for i in range(n) ]
  ...
  # whoops, our outside i has now been modified


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: