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

Yes, in Python 2.7 onward:

  s = {i**2 for i in range(10) if i} 
and the colon is what makes the dict comprehension different from the set comprehension:

  d - {i:i**2 for i in range(10) if i}


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

Search: