4 ms·
Your Python example is far from idiomatic, though. If a Python programmer were forced to write `Stuff`, they'd write something like: class Stuff: d
by gvx 5y ago
Your Python example is far from idiomatic, though. If a Python programmer were forced to write `Stuff`, they'd write something like:
class Stuff:
def __init__(self):
self.a_list = [1,2,3,4]
def __iter__(self):
return iter(self.a_list)
--- or do what the other person did, and make `__iter__` a generator, which isn't necessary in this case but is much more flexible.
- softwaredoug 5y agoYes, but if you’re new to Python you’re not going to grok this.