classification
Title: Add a turtle module function to draw a circle centered at the turtle
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Yehuda, eric.smith, glingl, nicktimko, rhettinger, willingc
Priority: normal Keywords:

Created on 2019-08-28 12:58 by Yehuda, last changed 2019-08-30 07:50 by Yehuda. This issue is now closed.

Files
File name Uploaded Description Edit
untitled.py Yehuda, 2019-08-28 12:58
Untitled-1.jpg Yehuda, 2019-08-29 19:16
Messages (21)
msg350662 - (view) Author: Yehuda Katz (Yehuda) Date: 2019-08-28 12:58
1 - turtle bug: If I don't put parenthesis at the end of a line, I don't get error message. Try this:
====================
from turtle import *
fd(50); rt
done()
====================

2 - request: Highly desirable a function that draws a circle with radius n  AROUND THE TURTLE.

Thank you and have a wonderful day.
msg350666 - (view) Author: Nick Timkovich (nicktimko) * Date: 2019-08-28 16:04
Regarding #1: In Python, you may refer to a variable's name (e.g. `rt`, which is a function), which often has no effect in a script. In the REPL (where you see >>>) it is useful to inspect the object:

>>> turtle.rt
<function rt at 0x7f14b8d46ea0>

In order to call that name/function, parentheses are *required* unlike other languages where they are optional (Ruby). So, you don't get an error message, but one is not expected. Linting tools can alert you to statements that don't appear to have an effect.

Regarding #2: Students of the turtle could create a reusable function to draw a circle with the turtle and return to the starting position. It would be an excellent exercise with multiple solutions!
msg350669 - (view) Author: Yehuda Katz (Yehuda) Date: 2019-08-28 16:26
Sorry to say but these don't satisfy my issues.

1 the next code SHOULD produce an error message. Think that it's followed
by a few dozens of code lines:
from turtle import *
fd; rt(90)
2 Old Logo had a useful function of creating a circle AROUND THE TURTLE. It
would be very nice it such a function was built-in in turtle module.
Giving this to student as a problem is not a good answer, it's more like a
sort of "pass the baby" solution.

Thank you for the fast reply.

Yehuda Katz (Israel)

On Wed, Aug 28, 2019 at 7:04 PM Nick Timkovich <report@bugs.python.org>
wrote:

>
> Nick Timkovich <prometheus235@gmail.com> added the comment:
>
> Regarding #1: In Python, you may refer to a variable's name (e.g. `rt`,
> which is a function), which often has no effect in a script. In the REPL
> (where you see >>>) it is useful to inspect the object:
>
> >>> turtle.rt
> <function rt at 0x7f14b8d46ea0>
>
> In order to call that name/function, parentheses are *required* unlike
> other languages where they are optional (Ruby). So, you don't get an error
> message, but one is not expected. Linting tools can alert you to statements
> that don't appear to have an effect.
>
> Regarding #2: Students of the turtle could create a reusable function to
> draw a circle with the turtle and return to the starting position. It would
> be an excellent exercise with multiple solutions!
>
> ----------
> nosy: +nicktimko
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue37968>
> _______________________________________
>
msg350670 - (view) Author: Yehuda Katz (Yehuda) Date: 2019-08-28 16:29
Hi,

Sorry to say but these don't satisfy my issues.

1 the next code SHOULD produce an error message. Think that it's followed
by a few dozens of code lines:
from turtle import *
fd; rt(90)
2 Old Logo had a useful function of creating a circle AROUND THE TURTLE. It
would be very nice it such a function was built-in in Python's turtle
module.
Giving this to student as a problem is not a good answer, it's more like a
sort of "pass the baby" solution.

Thank you for the fast reply.

On Wed, Aug 28, 2019 at 7:26 PM Yehuda Katz <report@bugs.python.org> wrote:

>
> Yehuda Katz <katye2007@gmail.com> added the comment:
>
> Sorry to say but these don't satisfy my issues.
>
> 1 the next code SHOULD produce an error message. Think that it's followed
> by a few dozens of code lines:
> from turtle import *
> fd; rt(90)
> 2 Old Logo had a useful function of creating a circle AROUND THE TURTLE. It
> would be very nice it such a function was built-in in turtle module.
> Giving this to student as a problem is not a good answer, it's more like a
> sort of "pass the baby" solution.
>
> Thank you for the fast reply.
>
> Yehuda Katz (Israel)
>
> On Wed, Aug 28, 2019 at 7:04 PM Nick Timkovich <report@bugs.python.org>
> wrote:
>
> >
> > Nick Timkovich <prometheus235@gmail.com> added the comment:
> >
> > Regarding #1: In Python, you may refer to a variable's name (e.g. `rt`,
> > which is a function), which often has no effect in a script. In the REPL
> > (where you see >>>) it is useful to inspect the object:
> >
> > >>> turtle.rt
> > <function rt at 0x7f14b8d46ea0>
> >
> > In order to call that name/function, parentheses are *required* unlike
> > other languages where they are optional (Ruby). So, you don't get an
> error
> > message, but one is not expected. Linting tools can alert you to
> statements
> > that don't appear to have an effect.
> >
> > Regarding #2: Students of the turtle could create a reusable function to
> > draw a circle with the turtle and return to the starting position. It
> would
> > be an excellent exercise with multiple solutions!
> >
> > ----------
> > nosy: +nicktimko
> >
> > _______________________________________
> > Python tracker <report@bugs.python.org>
> > <https://bugs.python.org/issue37968>
> > _______________________________________
> >
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue37968>
> _______________________________________
>
msg350672 - (view) Author: Nick Timkovich (nicktimko) * Date: 2019-08-28 16:55
Resolving #1 as you suggest is next to impossible. Python can not deduce if you meant to call the function or just refer to its name. Admittedly, the latter is strange in non-interactive contexts, but it is valid.

#2, as far as I can tell Logo had an ARC command:

ARC angle radius

	draws an arc of a circle, with the turtle at the center, 
	with the specified radius, starting at the turtle's 
	heading and extending clockwise through the specified 
	angle.  The turtle does not move.

I guess I don't know the history about why there's turtle.circle in Python which *does* move the turtle, and has the center *not* at the turtle. Adding an equivalent "turtle.arc" function might be useful, though the naming would be a bit confusing. Can you propose a better name and define exactly how it would work?
msg350673 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2019-08-28 17:06
> 1 the next code SHOULD produce an error message. Think that it's followed
> by a few dozens of code lines:
> from turtle import *
> fd; rt(90)

There's no reasonable mechanism in current Python by which this could produce an error message; it's not an error, and you'd need to make substantial changes to the core language to make it such, including fleshing out exactly what those changes would be and how they'd work, and persuading other core developers that those changes improve the language.

As Nick Timkovich points out, tools like pylint will flag this sort of thing. When I run pylint on your script, the output includes the following:

> untitled.py:3:8: W0104: Statement seems to have no effect (pointless-statement) 

If you really want to pursue the necessary changes in the core language, I'd suggest starting a discussion on the python-ideas mailing list; others may have innovative suggestions for ameliorating the core problem. But it's just not feasible in the language as it stands.

I'd suggest focusing this issue on your second item, and dropping the first.
msg350674 - (view) Author: Yehuda Katz (Yehuda) Date: 2019-08-28 17:08
Such a function would be welcomed.
For the best of my (limited) knowledge, there's currently no arc() function
in module turtle.

I can't think about a proper name... Sorry.

Yehuda

On Wed, Aug 28, 2019 at 7:55 PM Nick Timkovich <report@bugs.python.org>
wrote:

>
> Nick Timkovich <prometheus235@gmail.com> added the comment:
>
> Resolving #1 as you suggest is next to impossible. Python can not deduce
> if you meant to call the function or just refer to its name. Admittedly,
> the latter is strange in non-interactive contexts, but it is valid.
>
> #2, as far as I can tell Logo had an ARC command:
>
> ARC angle radius
>
>         draws an arc of a circle, with the turtle at the center,
>         with the specified radius, starting at the turtle's
>         heading and extending clockwise through the specified
>         angle.  The turtle does not move.
>
> I guess I don't know the history about why there's turtle.circle in Python
> which *does* move the turtle, and has the center *not* at the turtle.
> Adding an equivalent "turtle.arc" function might be useful, though the
> naming would be a bit confusing. Can you propose a better name and define
> exactly how it would work?
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue37968>
> _______________________________________
>
msg350678 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2019-08-28 17:29
Updated title, type and Python version (this would be a new feature, so would be targeted at Python 3.9).
msg350683 - (view) Author: Yehuda Katz (Yehuda) Date: 2019-08-28 18:08
G-R-E-A-T.

Yehuda,
Israel

On Wed, Aug 28, 2019 at 8:29 PM Mark Dickinson <report@bugs.python.org>
wrote:

>
> Mark Dickinson <dickinsm@gmail.com> added the comment:
>
> Updated title, type and Python version (this would be a new feature, so
> would be targeted at Python 3.9).
>
> ----------
> components: +Library (Lib)
> title: The turtle -> Add a turtle module function to draw a circle
> centered at the turtle
> type:  -> enhancement
> versions: +Python 3.9 -Python 3.7
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue37968>
> _______________________________________
>
msg350684 - (view) Author: Yehuda Katz (Yehuda) Date: 2019-08-28 18:09
G-R-E-A-T.

Yehuda (Israel)

On Wed, Aug 28, 2019 at 8:29 PM Mark Dickinson <report@bugs.python.org>
wrote:

>
> Mark Dickinson <dickinsm@gmail.com> added the comment:
>
> Updated title, type and Python version (this would be a new feature, so
> would be targeted at Python 3.9).
>
> ----------
> components: +Library (Lib)
> title: The turtle -> Add a turtle module function to draw a circle
> centered at the turtle
> type:  -> enhancement
> versions: +Python 3.9 -Python 3.7
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue37968>
> _______________________________________
>
msg350693 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-08-28 23:23
> For the best of my (limited) knowledge, there's currently
> no arc() function in module turtle.

circle() takes a second argument called "extent":

   circle(200, 90)    # draw 90° of a circle of radius 200

FWIW, searching the turtle documentation page for "arc" immediately finds the two argument form of circle, so I don't think there is a discoverability problem.

Suggestion for Yehuda:  Consider driving the turtle module from IPython.  It has an "%autocall" mode that automatically adds parentheses.  For example:

    forward 100
    right 90

gets automatically transformed to:
    forward(100)
    right(90)

FWIW, I concur with Nick that we shouldn't add a new circle function centered on the turtle.  He was correct that this would make a great exercise.   More importantly, making the module bigger doesn't make it easier to use (see https://en.wikipedia.org/wiki/Overchoice ).  You've already indicated that you don't yet know the full API and haven't found essential tools like the two argument form of circle(), so making the API bigger would likely have made the discoverability problem worse.

At this point, I think we should close this tracker issue:

* It's not easily possible to make "rt" generate an error message
* Circle centered on a turtle is best left as an exercise
* arc() is already present in the two argument form of circle()

One other thought:  The Python API was based on other turtle implementations, so the API is probably mostly already where it should be.
msg350694 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-08-28 23:24
Also see:  https://en.wikipedia.org/wiki/The_Paradox_of_Choice
msg350698 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-08-29 00:22
I agree that we should close this and not implement a function to draw a circle centered on the turtle. The fundamental abstraction with turtle graphics is that the turtle is holding a pen. To have the pen draw elsewhere, where the turtle does not go, breaks the abstraction.
msg350699 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-08-29 00:36
Yehuda, thank you for the suggestions, but we're going to decline.
msg350730 - (view) Author: Yehuda Katz (Yehuda) Date: 2019-08-29 06:29
Thanks for the clarifications.
Yehuda(Israel)

On Thu, Aug 29, 2019 at 3:36 AM Raymond Hettinger <report@bugs.python.org>
wrote:

>
> Raymond Hettinger <raymond.hettinger@gmail.com> added the comment:
>
> Yehuda, thank you for the suggestions, but we're going to decline.
>
> ----------
> resolution:  -> rejected
> stage:  -> resolved
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue37968>
> _______________________________________
>
msg350733 - (view) Author: Yehuda Katz (Yehuda) Date: 2019-08-29 06:30
Thanks for the clarifications.
Yehuda(Israel)

On Thu, Aug 29, 2019 at 3:36 AM Raymond Hettinger <report@bugs.python.org>
wrote:

>
> Raymond Hettinger <raymond.hettinger@gmail.com> added the comment:
>
> Yehuda, thank you for the suggestions, but we're going to decline.
>
> ----------
> resolution:  -> rejected
> stage:  -> resolved
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue37968>
> _______________________________________
>
msg350816 - (view) Author: Yehuda Katz (Yehuda) Date: 2019-08-29 19:16
Hi Mark,
Function arc() might be in the documents, but not in practice.
Please see the attachment.
Yehuda

On Wed, Aug 28, 2019 at 8:29 PM Mark Dickinson <report@bugs.python.org>
wrote:

>
> Mark Dickinson <dickinsm@gmail.com> added the comment:
>
> Updated title, type and Python version (this would be a new feature, so
> would be targeted at Python 3.9).
>
> ----------
> components: +Library (Lib)
> title: The turtle -> Add a turtle module function to draw a circle
> centered at the turtle
> type:  -> enhancement
> versions: +Python 3.9 -Python 3.7
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue37968>
> _______________________________________
>
msg350827 - (view) Author: Nick Timkovich (nicktimko) * Date: 2019-08-29 20:40
To clarify, there is an "ARC" command in Logo that draws a circle/circle segment *centered on* the turtle. Reference: http://fmslogo.sourceforge.net/manual/command-arc.html Examples: https://personal.utdallas.edu/~veerasam/logo/ That command is not/has not been implemented in Python's turtle graphics. 

As Eric mentioned, it could be considered a benefit as the principle of turtle graphics is that turtles have no arms to move the pen away from their body (adolescent abnormal assassin turtles, notwithstanding).
msg350829 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-08-29 20:47
It's turtle.circle: 

https://docs.python.org/3.5/library/turtle.html#turtle.circle

@Yehuda: this isn't the appropriate place for help on how the turtle module works. Please consider the python-tutor list. See https://mail.python.org/mailman/listinfo/tutor
msg350830 - (view) Author: Yehuda Katz (Yehuda) Date: 2019-08-29 20:50
Nick, thank you. What you linked here is Logo, with different logic &
syntax than Python.
The hand analogy is interesting, thank you.
I rest my case and have good night from Israel.

Yehuda

On Thu, Aug 29, 2019 at 11:40 PM Nick Timkovich <report@bugs.python.org>
wrote:

>
> Nick Timkovich <prometheus235@gmail.com> added the comment:
>
> To clarify, there is an "ARC" command in Logo that draws a circle/circle
> segment *centered on* the turtle. Reference:
> http://fmslogo.sourceforge.net/manual/command-arc.html Examples:
> https://personal.utdallas.edu/~veerasam/logo/ That command is not/has not
> been implemented in Python's turtle graphics.
>
> As Eric mentioned, it could be considered a benefit as the principle of
> turtle graphics is that turtles have no arms to move the pen away from
> their body (adolescent abnormal assassin turtles, notwithstanding).
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue37968>
> _______________________________________
>
msg350859 - (view) Author: Yehuda Katz (Yehuda) Date: 2019-08-30 07:50
Eric, thank you, I'm sorry.
Yehuda

On Thu, Aug 29, 2019 at 11:47 PM Eric V. Smith <report@bugs.python.org>
wrote:

>
> Eric V. Smith <eric@trueblade.com> added the comment:
>
> It's turtle.circle:
>
> https://docs.python.org/3.5/library/turtle.html#turtle.circle
>
> @Yehuda: this isn't the appropriate place for help on how the turtle
> module works. Please consider the python-tutor list. See
> https://mail.python.org/mailman/listinfo/tutor
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue37968>
> _______________________________________
>
History
Date User Action Args
2019-08-30 07:50:08Yehudasetmessages: + msg350859
2019-08-29 20:50:42Yehudasetmessages: + msg350830
2019-08-29 20:47:42eric.smithsetmessages: + msg350829
2019-08-29 20:40:13nicktimkosetmessages: + msg350827
2019-08-29 19:16:09Yehudasetfiles: + Untitled-1.jpg

messages: + msg350816
2019-08-29 06:30:48Yehudasetmessages: + msg350733
2019-08-29 06:29:44Yehudasetmessages: + msg350730
2019-08-29 00:36:09rhettingersetstatus: open -> closed
resolution: rejected
messages: + msg350699

stage: resolved
2019-08-29 00:22:42eric.smithsetnosy: + eric.smith
messages: + msg350698
2019-08-28 23:24:10rhettingersetmessages: + msg350694
2019-08-28 23:23:11rhettingersetnosy: + rhettinger
messages: + msg350693
2019-08-28 18:09:52Yehudasetmessages: + msg350684
2019-08-28 18:08:16Yehudasetmessages: + msg350683
2019-08-28 17:31:45mark.dickinsonsetnosy: + glingl, willingc, - mark.dickinson
2019-08-28 17:29:34mark.dickinsonsetversions: + Python 3.9, - Python 3.7
title: The turtle -> Add a turtle module function to draw a circle centered at the turtle
messages: + msg350678

components: + Library (Lib)
type: enhancement
2019-08-28 17:08:26Yehudasetmessages: + msg350674
2019-08-28 17:06:51mark.dickinsonsetnosy: + mark.dickinson
messages: + msg350673
2019-08-28 16:55:17nicktimkosetmessages: + msg350672
2019-08-28 16:29:35Yehudasetmessages: + msg350670
2019-08-28 16:26:48Yehudasetmessages: + msg350669
2019-08-28 16:04:22nicktimkosetnosy: + nicktimko
messages: + msg350666
2019-08-28 12:58:20Yehudacreate