Search code examples
pythonpycharmpython-itertools

Pycharm debuger disconects


Hi I have list of four directions and method like

directions = ["NORTH", "EAST", "SOUTH", "WEST"]
def rotate_left(self):
    cycled = cycle(self.directions)
    current = dropwhile(lambda x: x != self.direction, cycled)
    self.direction = next(current)

but somehow after this method my program stops without any exception

any idea why? Thanks


Solution

  • It seems that problem was that dropwhile() condition could never come true in my code. Due to pythons lazy execution it seemed that problem was with me calling next(), but it was only because that was when dropwhile() executed, causing it to cycle thru endless List without ever completing condition.

    Sorry for wasting your time everybody.