python / cpython

The Python programming language
https://www.python.org
Other
63.35k stars 30.34k forks source link

Add a turtle module function to draw a circle centered at the turtle #82149

Closed c4b45b0b-fc0b-4ce6-a6fd-614eb320b4d0 closed 5 years ago

c4b45b0b-fc0b-4ce6-a6fd-614eb320b4d0 commented 5 years ago
BPO 37968
Nosy @rhettinger, @ericvsmith, @nicktimko, @willingc
Files
  • untitled.py
  • Untitled-1.jpg
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields: ```python assignee = None closed_at = created_at = labels = ['type-feature', 'library', '3.9'] title = 'Add a turtle module function to draw a circle centered at the turtle' updated_at = user = 'https://bugs.python.org/Yehuda' ``` bugs.python.org fields: ```python activity = actor = 'Yehuda' assignee = 'none' closed = True closed_date = closer = 'rhettinger' components = ['Library (Lib)'] creation = creator = 'Yehuda' dependencies = [] files = ['48564', '48572'] hgrepos = [] issue_num = 37968 keywords = [] message_count = 21.0 messages = ['350662', '350666', '350669', '350670', '350672', '350673', '350674', '350678', '350683', '350684', '350693', '350694', '350698', '350699', '350730', '350733', '350816', '350827', '350829', '350830', '350859'] nosy_count = 6.0 nosy_names = ['rhettinger', 'glingl', 'eric.smith', 'nicktimko', 'willingc', 'Yehuda'] pr_nums = [] priority = 'normal' resolution = 'rejected' stage = 'resolved' status = 'closed' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue37968' versions = ['Python 3.9'] ```

    c4b45b0b-fc0b-4ce6-a6fd-614eb320b4d0 commented 5 years ago

    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.

    47e28231-cd8d-42e1-9eb3-d608b8430a1c commented 5 years ago

    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!

    c4b45b0b-fc0b-4ce6-a6fd-614eb320b4d0 commented 5 years ago

    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\


    c4b45b0b-fc0b-4ce6-a6fd-614eb320b4d0 commented 5 years ago

    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\


    47e28231-cd8d-42e1-9eb3-d608b8430a1c commented 5 years ago

    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?

    mdickinson commented 5 years ago

    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.

    c4b45b0b-fc0b-4ce6-a6fd-614eb320b4d0 commented 5 years ago

    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\


    mdickinson commented 5 years ago

    Updated title, type and Python version (this would be a new feature, so would be targeted at Python 3.9).

    c4b45b0b-fc0b-4ce6-a6fd-614eb320b4d0 commented 5 years ago

    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\


    c4b45b0b-fc0b-4ce6-a6fd-614eb320b4d0 commented 5 years ago

    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\


    rhettinger commented 5 years ago

    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:

    One other thought: The Python API was based on other turtle implementations, so the API is probably mostly already where it should be.

    rhettinger commented 5 years ago

    Also see: https://en.wikipedia.org/wiki/The_Paradox_of_Choice

    ericvsmith commented 5 years ago

    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.

    rhettinger commented 5 years ago

    Yehuda, thank you for the suggestions, but we're going to decline.

    c4b45b0b-fc0b-4ce6-a6fd-614eb320b4d0 commented 5 years ago

    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\


    c4b45b0b-fc0b-4ce6-a6fd-614eb320b4d0 commented 5 years ago

    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\


    c4b45b0b-fc0b-4ce6-a6fd-614eb320b4d0 commented 5 years ago

    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\


    47e28231-cd8d-42e1-9eb3-d608b8430a1c commented 5 years ago

    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).

    ericvsmith commented 5 years ago

    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

    c4b45b0b-fc0b-4ce6-a6fd-614eb320b4d0 commented 5 years ago

    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\


    c4b45b0b-fc0b-4ce6-a6fd-614eb320b4d0 commented 5 years ago

    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\