SAS7BDAT should not subclass Iterator

Issue #8 resolved
Matthew Rocklin created an issue

Currently

>>> issubclass(sas7bdat.SAS7BDAT, Iterator)
True

because this object implements __next__. This is somewhat atypical because it means that the main object to represent persistent data also holds on to the state of iteration. There is now only one possible iterator (not several.) So, for example, repeated attempts to get the first five entries of a file through iteration will receive a different set of five entries.

Rather than defining __next__ explicitly it is much more common to just define __iter__ and have that method return an iterator like the result of calling readlines.

So I suggest the following changes

  • Delete the __next__ method
  • redefine __iter__ to return self.readlines() rather than self

Comments (1)

  1. Log in to comment