-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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-88773: Added teleport method to Turtle library #103974
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
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 cannot comment on the desirability of the addition until I have time to test and verify justification assertion. Not now.
Nor have I reviewed the new tkinter code.
Blurb needs expansion. I will commit my proposal and you can propose further revision.
Doc and test additions are needed before merge.
Note: Topics are for issues. Core developers get notified of PRs by signing up as 'code owner' of specific files. Besides which, this does not touch tkinter.
Misc/NEWS.d/next/Library/2023-04-28-18-04-23.gh-issue-88773.xXCNJw.rst
Outdated
Show resolved
Hide resolved
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
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.
Please also document this in Doc/library/turtle.rst
. Be sure to include a .. versionadded: 3.12
annotation on the new teleport method documentation in there.
Terry and Gregory, thank you for taking the time to review this PR. If you're wondering where to add tests, they are found in Documentation help can be found here https://devguide.python.org/documentation/ . I also sent you an email to discuss CPython contribution. Please take a look when you have the time. Thanks! |
Misc/NEWS.d/next/Library/2023-04-28-18-04-23.gh-issue-88773.xXCNJw.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
…CNJw.rst Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Thanks for making the requested changes! @terryjreedy, @gpshead: please review the changes made to this pull request. |
stamp ids are global an incrementing, do not expose them as doctest constants.
I wish the turtle module was a 3rd party package, but since it isn't, and is actively used, I think this is a good contribution. I hope @gpshead will come through with his promise of review of the PR. (I didn't see anything objectionable on a quick skim.) |
I have made the requested changes; please review again. |
Thanks for making the requested changes! @gpshead, @terryjreedy: please review the changes made to this pull request. |
* main: (26 commits) pythongh-104028: Reduce object creation while calling callback function from gc (pythongh-104030) pythongh-104036: Fix direct invocation of test_typing (python#104037) pythongh-102213: Optimize the performance of `__getattr__` (pythonGH-103761) pythongh-103895: Improve how invalid `Exception.__notes__` are displayed (python#103897) Adjust expression from `==` to `!=` in alignment with the meaning of the paragraph. (pythonGH-104021) pythongh-88496: Fix IDLE test hang on macOS (python#104025) Improve int test coverage (python#104024) pythongh-88773: Added teleport method to Turtle library (python#103974) pythongh-104015: Fix direct invocation of `test_dataclasses` (python#104017) pythongh-104012: Ensure test_calendar.CalendarTestCase.test_deprecation_warning consistently passes (python#104014) pythongh-103977: compile re expressions in platform.py only if required (python#103981) pythongh-98003: Inline call frames for CALL_FUNCTION_EX (pythonGH-98004) Replace Netlify with Read the Docs build previews (python#103843) Update name in acknowledgements and add mailmap (python#103696) pythongh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (python#103927) Remove non-existing tools from Sundry skiplist (python#103991) pythongh-103793: Defer formatting task name (python#103767) pythongh-87092: change assembler to use instruction sequence instead of CFG (python#103933) pythongh-103636: issue warning for deprecated calendar constants (python#103833) Various small fixes to dis docs (python#103923) ...
Fully implemented and tested a teleport method as described by the issue. This method behaves differently from the
goto
(orsetpos
) method, and can be especially helpful when creating and filling multiple separate objects.Implementation:
There already exists a
goto
method, aliased assetpos | setposition | goto
. It basically moves the turtle to the given position, but if the pen is down, it draws a line along the path. Additionally, the move is not instant, and you can see it go along the path to get to the destination. Users of the library may find themselves raising the pen, calling the method, and then lowering it so that a line doesn’t get drawn. Another issue with using goto for this is that regardless of whether the pen is raised, an "imaginary" line is still drawn from the current position to the destination. When filling is enabled, this invisible line acts as a boundary for the fill color. If one were creating multiple separate objects with filling enabled, they would need to run the exact code in the teleport method in order to fill them separately as desired. The following is a demo of the difference betweengoto
andteleport
for filling multiple objects.Justification:
One might think we should just update the
goto
method to behave this way with a flag liketeleport=True
. However, all of the pen controlling methods are in one class,TPen
, and all of the visual and position controlling methods are in another,TNavigator
. The primary turtle class,RawTurtle(TPen, TNavigator)
inherits methods from both of these, and since teleport needs access to methods and attributes in both of these classes, this is where it should be written. While it would be possible to givegoto
access to theTPen
class via inheritance, this would be a messy refactor for what should be a distinct method.Resolves #88773