Hacker News new | past | comments | ask | show | jobs | submit login

for i in xrange(1000000000): print i

xrange() addresses the problem you describe and has been in Python since, like, forever. However, range() is nicer for learning the language, since it's easy to see how it composes into a list.




Yes, I know. It's just bad that people are taught one way of iterating, and then may or may not learn the right way at some later time.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: