-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-126349 Add context managers to turtle for fill
, poly
and no_animation
#126350
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Marie Roald <[email protected]>
Co-authored-by: Yngve Mardal Moe <[email protected]>
Co-authored-by: Yngve Mardal Moe <[email protected]>
Co-authored-by: Marie Roald <[email protected]>
Co-authored-by: Marie Roald <[email protected]>
This comment was marked as outdated.
This comment was marked as outdated.
Co-authored-by: Yngve Mardal Moe <[email protected]>
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a note about these additions to the Doc/whatsnew/3.14.rst
?
Doc/library/turtle.rst
Outdated
Automatically begin and end filling | ||
----------------------------------- | ||
|
||
If you have Python 3.14 or later, you don't need to call :func:`begin_fill` and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't usually include things like "If you have Python 3.14 or later" because each set of docs relates to one specific Python version.
But perhaps it's okay here because turtle is often used by beginners who might read these docs but have 3.12 or 3.13 installed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes a lot of sense, but in this specific case I think it's useful. Many learners are at universities or schools with old versions of Python, and they might not be aware that there are several versions of Python. So I think it's useful to make it very clear that this is a new feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to reopen, but IMO this reads a little bit unexpected. How about something in the lines of:
Starting with Python 3.14, you can use [...] instead of [...].
What do you think?
Lib/turtle.py
Outdated
@@ -110,27 +110,30 @@ | |||
from copy import deepcopy | |||
from tkinter import simpledialog | |||
|
|||
from contextlib import contextmanager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the extra newline between this and the previous import statement?
Co-authored-by: Hugo van Kemenade <[email protected]> Co-authored-by: Daniel Hollas <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]> Co-authored-by: Daniel Hollas <[email protected]>
We have tried to address the review comments now 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some final minor nitpicks. Otherwise looks great!
Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Marie Roald <[email protected]>
Co-authored-by: Marie Roald <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last one and I am good! (modulo Hugo's comment)
Co-authored-by: Yngve Mardal Moe <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I promise there really shouldn't have anything left for me. Thank you for your patience! (my reviews tend to have multiple parts depending on the hour when I do the review).
Co-authored-by: Bénédikt Tran <[email protected]>
No worries, thanks a lot for the thorough review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, but I have some remarks and nits. PTAL.
Doc/library/turtle.rst
Outdated
Automatically begin and end filling | ||
----------------------------------- | ||
|
||
If you have Python 3.14 or later, you don't need to call :func:`begin_fill` and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to reopen, but IMO this reads a little bit unexpected. How about something in the lines of:
Starting with Python 3.14, you can use [...] instead of [...].
What do you think?
Doc/library/turtle.rst
Outdated
... dist = 2 | ||
... for i in range(200): | ||
... fd(dist) | ||
... rt(90) | ||
... dist += 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be written more compact. Though, I'm not sure it is more readable, so feel free to ignore this :)
... dist = 2 | |
... for i in range(200): | |
... fd(dist) | |
... rt(90) | |
... dist += 2 | |
... for dist in range(0, 400, 2): | |
... fd(dist+2) | |
... rt(90) |
Lib/turtle.py
Outdated
"""Record the vertices of a polygon. | ||
|
||
No argument. | ||
|
||
Record the vertices of a polygon. Current turtle position is first point | ||
of polygon. This function sets up a context manager that will | ||
automatically end recording once exited. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: Yngve Mardal Moe <[email protected]>
Adds
fill()
,poly()
andno_animation()
context managers to turtle.py.Co-authored-by: Yngve Mardal Moe [email protected]
fill
,poly
andtracer
#126349📚 Documentation preview 📚: https://cpython-previews--126350.org.readthedocs.build/en/126350/library/turtle.html