This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Turtle demo
Type: behavior Stage:
Components: Tests Versions: Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Davide Golinelli, steven.daprano
Priority: normal Keywords:

Created on 2020-03-30 11:32 by Davide Golinelli, last changed 2022-04-11 14:59 by admin.

File name Uploaded Description Edit Davide Golinelli, 2020-03-30 11:32
backwards.png Davide Golinelli, 2020-03-30 13:11
Messages (6)
msg365303 - (view) Author: Davide Golinelli (Davide Golinelli) Date: 2020-03-30 11:32
running the attacched simple program the turtle go backwards even if not asked.

i added a sleep command in order to view the bug more easly
msg365306 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2020-03-30 12:05
Perhaps this is just my old eyes, but I can't see where the turtle is going backwards. I can see it spinning, but it's not clear that the turtle position is moving backwards or if it is an illusion caused by the turtle spinning around.

If your eyes are better and can see the backward motion, perhaps you could adjust the drawing to make it more obvious. Hide the turtle and change the pen colour perhaps?
msg365308 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2020-03-30 12:16
Try changing the turtle to the arrow pointer and see if you can still see backwards movement.

msg365310 - (view) Author: Davide Golinelli (Davide Golinelli) Date: 2020-03-30 13:11
I attacched a picture where you can see the cursor drawing backwars.

the program is supposed to draw a function like y=sin(x) but is drawing y=abs(sin(x)).
msg365444 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2020-04-01 00:47
> the program is supposed to draw a function like y=sin(x) but is drawing y=abs(sin(x)).

It would have been nice if you had described the problem this way from your initial bug report, instead of saying that the turtle was moving backwards. I understood "moving backwards" as it going back over its own path, retracing its steps. I wasted a lot of time peering carefully at the screen trying to see where the turtle was retracing its steps.

Now I understand you mean the turtle is moving in the opposite direction from that it is facing. Gotcha.

You titled this bug report "Turtle demo", but I can't find it listed in the turtle demo here:

Where did you get this demo from? If it's not from the standard library, you should report this to the author, as it is a bug in their code, not the turtle module, caused by mishandling of negative numbers. If you move *forward* by a *negative* amount, of course you are going in the opposite direction to that you are facing.

So the spike() function is buggy. There are probably many ways to fix it, depending on what you intend it to do, but probably the simplest is to just add a call to abs() before calling forward:

msg365451 - (view) Author: Davide Golinelli (Davide Golinelli) Date: 2020-04-01 07:08
you're absolutely right! 
I'm so sorry for wasting your time.

thanks and regards
Date User Action Args
2022-04-11 14:59:28adminsetgithub: 84294
2020-04-01 07:08:17Davide Golinellisetmessages: + msg365451
2020-04-01 00:47:50steven.dapranosetmessages: + msg365444
2020-03-30 13:11:47Davide Golinellisetfiles: + backwards.png

messages: + msg365310
2020-03-30 12:16:39steven.dapranosetmessages: + msg365308
2020-03-30 12:05:55steven.dapranosetnosy: + steven.daprano
messages: + msg365306
2020-03-30 11:32:25Davide Golinellicreate