3 ms·
I'm a longtime perl user, and I don't know where my blind spots are. Are there any particular resources you would recommend for someone like me to get going qu
by Sukotto 13y ago
I'm a longtime perl user, and I don't know where my blind spots are.
Are there any particular resources you would recommend for someone like me to get going quickly with python? In particular ones that specifically address the type of blind spot you mention?
- btilly 13y agoThe Python tutorial teaches the language fairly well: http://docs.python.org/2/tutorial/ http://docs.python.org/2/tutorial/ The iterator section is http://docs.python.org/2/tutorial/classes.html#iterators http://docs.python.org/2/tutorial/classes.html#iterators. Here it is quickly. Suppose that an object has a __iter__ method which will return something with a next method that will, when it has exhausted the iterator, call StopIteration. Then all native looping constructs can loop over that object and it will just work. If you call a function that internally calls yield and nowhere calls return, then you get back a generator, which is an object with those methods. There is also syntax to construct such generators inline without even an explicit function. All of the closure based looping stuff in HOP which supports potentially infinite streams? It is all built in!
- gonnakillme 13y agos/call StopIteration/raise StopIteration/g
- StavrosK 13y agoI wrote a tutorial a while ago exactly for this purpose: http://www.stavros.io/tutorials/python/ http://www.stavros.io/tutorials/python/