pyyaml.org
pyyaml.org copied to clipboard
Clarify that load_all methods return a generator, not a sequence
The documentation for load_all and safe_load_all states (emphasis mine):
... returns a sequence of Python objects ...
In reality, those methods return a generator, which is not the same thing as a sequence. For example:
with open(filename) as f:
docs = yaml.safe_load_all(f)
for d in docs:
# do stuff
will raise ValueError: I/O operation on closed file. which if docs was really a sequence doesn't make sense.
(Moved from https://github.com/yaml/pyyaml/issues/762)