Closed Negar-Amiri closed 1 year ago
Cheers @Negar-Amiri!
I couldn't have a careful look at your code right now, but I'm afraid Python's lists do not have a popleft()
method.
You could use .pop(0)
which can be slow/inefficient for large collections or create a deque
data structure that does have a .popleft()
and is perfect for these "history" things! https://github.com/jdf/processing.py/blob/master/mode/examples/Basics/Input/StoringInput/StoringInput.pyde
Please do open a thread at https://discourse.processing.org/c/processing-py/9 which is best place for us to discuss these things (here is for Processing.py bugs only, you might want to close this).
hello, and thank you so much for your answer
I find popleft() here in python docs 5.1.2. Using Lists as Queues
but anyway pop(0) works as well, thanks a lot.
I wrote a little program about a bouncer ball with an effortless physics engine and want to show the path that ball passed. so I decide to store the position of the ball in a list as a queue and when the list goes full, pop one of them from the left. but it seems to append() replaces all the list elements with the last position, instead of appending them. and also popleft() doesn't work. and also if anyone has a better idea for drawing passed paths, please let me know it.