This is almost certainly a result of my ignorance of how generators work, but I am completely lost.
If I interactively create the following generator:
iterator = iter(iterable)
prev = None
item = next(iterator)
for post in iterator:
prev = item
item = post
for prev,item,next in neighborhood([1,2,3,4,5]):
print(prev, item, next)
None 1 2
1 2 3
2 3 4
3 4 5
4 5 None
'NoneType' object is not callable"
When you did
for prev,item,next in ... # ^^^^
you shadowed the built-in
next function. The next time you try to use your generator, it fails because it gets your
next variable instead of the function it needed.