Although I sort of agree with Alister, I also note that many languages deliberately provide you with the means to customize in ways that make your personal life more amenable while making it perhaps harder for others.
Consider the humble import statement frequently used as: import numpy as np import pandas as pd The above is perfectly legal and in some circles is expected. But I suspect many people do not care about being able to type a slightly abbreviated np.name(..) rather than numpy.name(...) and yet others import specific functions from a package like: from numpy import arrange The bottom line is that there are many ways the same code can be called, including quite a few other variations I am not describing. People can customize their code in many ways including making it look more like the way they might program in some other computer language/environment. Anyone reading their code with a different viewpoint may have some adjustment issues. I am wondering if anyone has written programs that would take some complete body of code and not prettify it or reformat it as some tools do, but sort of make it into a standard format. In the above example, it might undo things like renaming numpy to np and change all the code that looks like np.name to numpy.name and similarly changes any function imported directly to also be fully qualified. Of course, some code I have seen changes things mid-stream or has some if statement that sets one of several function calls to be the one to use beyond that point. So, I am not sanguine on trying to enforce some standards to make your code easy to read by others and am more a fan of suggesting enough comments in the code to guide anyone on your own idiosyncratic uses. -----Original Message----- From: Python-list <python-list-bounces+avigross=verizon....@python.org> On Behalf Of alister via Python-list Sent: Tuesday, September 7, 2021 2:58 PM To: python-list@python.org Subject: Re: on writing a while loop for rolling two dice On Tue, 07 Sep 2021 14:53:29 +0000, Grant Edwards wrote: > On 2021-09-06, Stefan Ram <r...@zedat.fu-berlin.de> wrote: >> "Avi Gross" <avigr...@verizon.net> writes: >>> In languages like C/C++ there are people who make up macros like: >>>#define INDEFINITELY_LOOP while (true) Or something like that and >>>then allow the preprocessor to replace INDEFINITELY_LOOP with valid C >>>code. >> >> Those usually are beginners. >> >>>So, how to do something like that in python, is a challenge left to >>>the user >> >> Such a use of macros is frowned upon by most C programmers, >> because it renders the code unreadable. > > I remember engineering manager I worked with about 35 years ago who > used a set of C macros to try to make his code look as much like BASIC > as > possible: > > #define IF if ( #define THEN ) { #define ELSE } else { > #define ENDIF } > ... > > IIRC he copied them out of a magazine article. > > He then proceeded to try to implement a tree search algorithm (he > didn't actually know that's what he was doing) using his new > "language" without using recursion (which he had never heard of and > couldn't grok) by keeping track of state using an array. It did not go > well and made him a bit of a laughingstock. IIRC, he had first tried > to write it in actual BASIC, but gave up on that before switching to C > and his ridiculous macro set. 1 Simple rule, if you are programming in language 'a' then write Language 'a' Code it. Just because you can do something doesn't mean you should -- Help! I'm trapped in a Chinese computer factory! -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list