pynetbox
pynetbox copied to clipboard
Iterating over devices works only once
If I iterate over all devices as shown in the example code in the documentation it works only once. Ie if I write code like this:
>>> devices = nb.dcim.devices.all()
>>> for device in devices:
... print(device.name)
>>> for device in devices:
... print(device.name)
The print statement in the second for loop doesn't get executed. If I do another call to all() then I get another iterator but this introduces a noticable pause. You used to be able to do this without any pauses.
Is this working as designed?
Yep, see https://github.com/netbox-community/pynetbox/issues/374.
Thanks for that. I created a pull request to update the documentation to reflect this.
fixed and merged in #525