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.

classification
Title: Update demo files
Type: enhancement Stage: resolved
Components: Demos and Tools Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: ju-sh, rhettinger
Priority: normal Keywords: patch

Created on 2019-10-20 19:17 by ju-sh, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16890 merged ju-sh, 2019-10-22 15:18
PR 16896 merged rhettinger, 2019-10-23 03:38
Messages (7)
msg355013 - (view) Author: Julin (ju-sh) * Date: 2019-10-20 19:17
The demo programs inside Tools/demo, which is to guide people new to the language (that's the purpose, right?), makes use of several bad coding practices.

Like
 - `while 1:` being used instead of `while True:`
 - star import
 - function call and an `if` statement being on the same line, etc.

It can easily mislead someone new to the language especially since it is part of the codebase and part of distribution as well.

Can we update these files? Most of these seem have not been updated in some time.

A discussion touching this problem on #python-dev suggested that the demos were written when the docs were yet to be polished and now that we have a fully fledged documentation, maybe the demo files can be dropped.

But since the bpo has an option 'Demos and tools' under 'components', I guess maybe the demos are still considered essential.

What do you all think?
msg355014 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-10-20 19:59
The Tools/demo modules are sort of a quaint museum to the past.  That said, most of the code reads fine even by today's standards.

Go ahead with as PR to change "while 1" to "while True".

The star imports should remain (they are the norm for Tkinter) code.

Let's don't reformat the if/action pairs on the same line.  That reflects the author's way of thinking about the problem.  Though it may offend your stylistic sensibilities, it is valid Python and readable enough.

BTW, the scripts are almost never "guide people new to the language".  They are typically only found by experienced programmers exploring the tree of code (like little easter eggs).
msg355094 - (view) Author: Julin (ju-sh) * Date: 2019-10-21 18:16
Okay. While I'm at it, can I make a few minor change as well? Like

 - Use fstrings
 - change range(0, val) to range(val) as range()'s first argument has default value 0.
 - Change `for i in range(len(groups)):` to enumerated (redemo.py)
 - rename ss1.py to spreadsheet.py (to make its purpose clearer)
msg355111 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-10-22 02:04
Let's just do the rename for ss1.py.
msg355137 - (view) Author: Julin (ju-sh) * Date: 2019-10-22 15:37
I've made a PR. Can you review it?
msg355205 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-10-23 03:23
New changeset a4aeb336697c85996d781271cc6b42bc6d4c2908 by Raymond Hettinger (Julin S) in branch 'master':
bpo-38539: Update demo files (GH-16890)
https://github.com/python/cpython/commit/a4aeb336697c85996d781271cc6b42bc6d4c2908
msg355207 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-10-23 04:05
New changeset ea6041cd7ff0d752296d1759927eff898ceba864 by Raymond Hettinger in branch 'master':
bpo-38539:  Finish rename of ss1.py to spreadsheet.py (GH-16896)
https://github.com/python/cpython/commit/ea6041cd7ff0d752296d1759927eff898ceba864
History
Date User Action Args
2022-04-11 14:59:21adminsetgithub: 82720
2019-10-23 04:05:10rhettingersetmessages: + msg355207
2019-10-23 03:38:10rhettingersetpull_requests: + pull_request16434
2019-10-23 03:24:08rhettingersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-10-23 03:23:52rhettingersetmessages: + msg355205
2019-10-22 15:37:18ju-shsetmessages: + msg355137
2019-10-22 15:18:57ju-shsetkeywords: + patch
stage: patch review
pull_requests: + pull_request16428
2019-10-22 02:04:59rhettingersetmessages: + msg355111
2019-10-21 18:16:25ju-shsetmessages: + msg355094
2019-10-20 20:00:12rhettingersetassignee: rhettinger
versions: - Python 3.6, Python 3.7, Python 3.8
2019-10-20 19:59:51rhettingersetnosy: + rhettinger
messages: + msg355014
2019-10-20 19:17:35ju-shcreate