Python __iter__ and for loops
问题 As I understand it, I can use the for loop construction on an object with a __iter__ method that returns an iterator. I have an object for which I implement the following __getattribute__ method: def __getattribute__(self,name): if name in ["read","readlines","readline","seek","__iter__","closed","fileno","flush","mode","tell","truncate","write","writelines","xreadlines"]: return getattr(self.file,name) return object.__getattribute__(self,name) I have an object of this class, a for which the