Make ellipsis an indicator of missing implementation
In examples in the web very often we see unfinished or partial code, where the ellipsis "..." is used in place of missing instructions. Idea: make ellipsis used in that context throw an exception, reminding the user that this code is work in progress. The exception could be called ToDoError, or WorkInProgressError, or simply EllipsisError, and could be derived from NotImplementedError. ``` def my_fun(): ... # todo my_fun()
WorkInProgressError: Implementation of `my_fun` is not finished.
``` This change could break some code, as for now ellipsis in the middle of code is silently ignored, but I don't think anybody seriously relies on that behavior. haael
Raising an exception in that case would be a breaking change only for an aesthetic preference. Some codes use ellipsis as this in functions body and don't want it to raise an error. Also it's going to be confusing to understand why an exception is raised in that place. Le jeu. 27 avr. 2023 à 15:50, haael <haael@interia.pl> a écrit :
In examples in the web very often we see unfinished or partial code, where the ellipsis "..." is used in place of missing instructions.
Idea: make ellipsis used in that context throw an exception, reminding the user that this code is work in progress.
The exception could be called ToDoError, or WorkInProgressError, or simply EllipsisError, and could be derived from NotImplementedError.
```
def my_fun(): ... # todo
my_fun()
WorkInProgressError: Implementation of `my_fun` is not finished.
```
This change could break some code, as for now ellipsis in the middle of code is silently ignored, but I don't think anybody seriously relies on that behavior.
haael
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/QAU7LB... Code of Conduct: http://python.org/psf/codeofconduct/
-- Antoine Rozo
I agree. Giving punctuation-based syntax like ... a meaning that isn't obvious on reading the code makes for unreadable code. Whereas having `raise Exception ('TODO')` accomplishes the same thing but also allows English documentation. The ... here is open to interpretation, especially as a new feature to an old established language like Python. On Thu, Apr 27, 2023, 10:07 AM Antoine Rozo <antoine.rozo@gmail.com> wrote:
Raising an exception in that case would be a breaking change only for an aesthetic preference. Some codes use ellipsis as this in functions body and don't want it to raise an error. Also it's going to be confusing to understand why an exception is raised in that place.
Le jeu. 27 avr. 2023 à 15:50, haael <haael@interia.pl> a écrit :
In examples in the web very often we see unfinished or partial code, where the ellipsis "..." is used in place of missing instructions.
Idea: make ellipsis used in that context throw an exception, reminding the user that this code is work in progress.
The exception could be called ToDoError, or WorkInProgressError, or simply EllipsisError, and could be derived from NotImplementedError.
```
def my_fun(): ... # todo
my_fun()
WorkInProgressError: Implementation of `my_fun` is not finished.
```
This change could break some code, as for now ellipsis in the middle of code is silently ignored, but I don't think anybody seriously relies on that behavior.
haael
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/QAU7LB... Code of Conduct: http://python.org/psf/codeofconduct/
-- Antoine Rozo _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/6RX2H4... Code of Conduct: http://python.org/psf/codeofconduct/
Moreover, I have worked on a lot of code where ellipsis is used to mean "this branch isn't implemented yet, but doing nothing isn't terrible." I don't love that code. I'd rather it use `pass` and a clarifying comment. But this change would make all that existing code much more broken. On Sat, Apr 29, 2023, 9:22 AM Al Sweigart <asweigart@gmail.com> wrote:
I agree. Giving punctuation-based syntax like ... a meaning that isn't obvious on reading the code makes for unreadable code. Whereas having `raise Exception ('TODO')` accomplishes the same thing but also allows English documentation. The ... here is open to interpretation, especially as a new feature to an old established language like Python.
On Thu, Apr 27, 2023, 10:07 AM Antoine Rozo <antoine.rozo@gmail.com> wrote:
Raising an exception in that case would be a breaking change only for an aesthetic preference. Some codes use ellipsis as this in functions body and don't want it to raise an error. Also it's going to be confusing to understand why an exception is raised in that place.
Le jeu. 27 avr. 2023 à 15:50, haael <haael@interia.pl> a écrit :
In examples in the web very often we see unfinished or partial code, where the ellipsis "..." is used in place of missing instructions.
Idea: make ellipsis used in that context throw an exception, reminding the user that this code is work in progress.
The exception could be called ToDoError, or WorkInProgressError, or simply EllipsisError, and could be derived from NotImplementedError.
```
def my_fun(): ... # todo
my_fun()
WorkInProgressError: Implementation of `my_fun` is not finished.
```
This change could break some code, as for now ellipsis in the middle of code is silently ignored, but I don't think anybody seriously relies on that behavior.
haael
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/QAU7LB... Code of Conduct: http://python.org/psf/codeofconduct/
-- Antoine Rozo _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/6RX2H4... Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/3SURW3... Code of Conduct: http://python.org/psf/codeofconduct/
Sorry, -1. Is this really worth the hassle when you can write (more explicitly) def my_fun(): raise NotImplementedError # todo Python has grown steadily more complicated in its lifetime. Usually for good reasons. But each additional feature adds to the learning curve and the maintenance burden. New features have to be justified by getting a consensus that the benefits outweigh the extra complexity. How would you decide what corner cases such as these would do: eval("...") exec("...") [ ... ][0] ... if x is None else y return ... and how would this affect the implementation of the compiler/interpreter? Best wishes Rob Cliffe On 27/04/2023 14:45, haael wrote:
In examples in the web very often we see unfinished or partial code, where the ellipsis "..." is used in place of missing instructions.
Idea: make ellipsis used in that context throw an exception, reminding the user that this code is work in progress.
The exception could be called ToDoError, or WorkInProgressError, or simply EllipsisError, and could be derived from NotImplementedError.
```
def my_fun(): ... # todo
my_fun()
WorkInProgressError: Implementation of `my_fun` is not finished.
```
This change could break some code, as for now ellipsis in the middle of code is silently ignored, but I don't think anybody seriously relies on that behavior.
haael
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/QAU7LB... Code of Conduct: http://python.org/psf/codeofconduct/
participants (5)
-
Al Sweigart
-
Antoine Rozo
-
David Mertz, Ph.D.
-
haael
-
Rob Cliffe