readability of sample programs in tutorial
Hi, when reading some of the sample codes in the official tutorial, I had to do research to understand the background of naming and string constants, like those strings from the script of Monty Python. Still this one in $5.5 is the most challenging so far:
tel = {'jack': 4098, 'sape': 4139} tel['guido'] = 4127 tel {'sape': 4139, 'guido': 4127, 'jack': 4098} tel['jack'] 4098 ...
I did quite some digging to confirm my guess of the hidden meaning, during which I realized it was initially written 27 years ago, without much change so far. Now I'm curious if its meaning is obvious to most nowadays beginners even as English speakers. In general, I wonder if there was discussion of revising some sample programs for better readability or adding more comments/introductory texts? Thanks.
On Fri, May 11, 2018 at 09:40:29AM -0700, Xuan Wu wrote:
tel = {'jack': 4098, 'sape': 4139} tel['guido'] = 4127 tel {'sape': 4139, 'guido': 4127, 'jack': 4098} tel['jack'] 4098 ...
I did quite some digging to confirm my guess of the hidden meaning, during which I realized it was initially written 27 years ago, without much change so far. Now I'm curious if its meaning is obvious to most nowadays beginners even as English speakers.
There's a hidden meaning? I thought they were just arbitrary keys and values. Obviously "guido" comes from the designer of Python, but I always thought that the rest are just arbitrary. -- Steve
Hi Steve, actually I suspected the same at the first sight, but after realizing "Guido" is the creator, I dug the python source code history and found out he actually drafted this sample himself around 1991. Then I found in his resume that:
From 1986 till 1991 I was with the Amoeba project, headed by Sape Mullender
Sape's phone back then at CWI was |+20-592 4139. | After that I found another colleague of them is Jack Jansen, with phone 20 592 4098 And 20-592-4127 might be a shared phone number, as it was listed as overall contact number in some of CWI's publications, so likely Guido and Irv (not sure who that refers to, which bothers me a bit still, but I can live with it) both used that at some time, which is also shown in the sample program. So, 'tel' seems to be a sample telephone book of CWI, with only the last 4 digits. The program's meaning becomes obvious only after all this history study. It was fun for sure, but IMO most readers won't go that far, as I didn't find any of such explanations online so far. Best, Xuan. On 5/11/18 9:40 AM, Xuan Wu wrote:
Hi,
when reading some of the sample codes in the official tutorial, I had to do research to understand the background of naming and string constants, like those strings from the script of Monty Python. Still this one in $5.5 is the most challenging so far:
tel = {'jack': 4098, 'sape': 4139} tel['guido'] = 4127 tel {'sape': 4139, 'guido': 4127, 'jack': 4098} tel['jack'] 4098 ...
I did quite some digging to confirm my guess of the hidden meaning, during which I realized it was initially written 27 years ago, without much change so far. Now I'm curious if its meaning is obvious to most nowadays beginners even as English speakers.
In general, I wonder if there was discussion of revising some sample programs for better readability or adding more comments/introductory texts?
Thanks.
Hi, On 12 May 2018 10:11 PM, Xuan Wu <fromwheretowhere.service@gmail.com> wrote:
The program's meaning becomes obvious only after all this history study.
Yes, but don't forgot that this is not a program (demonstrating usefull behavior), but a sample, demonstrating syntax.
It was fun for sure, but IMO most readers won't go that far, as I didn't find any of such explanations online so far.
Which is fine, as the example is OK to understand syntax. Understanding what authors had in mind back then while redacting examples is a whole other level of reading. PS: Good lunk understanding what the author of
words ['defenestrate', 'cat', 'window', 'defenestrate']
had in mind (yet it does not hurt readability of the example, IMHO). -- Julien Palard https://mdk.fr
Hi, On 5/13/18 2:02 AM, Julien Palard wrote:
Hi,
On 12 May 2018 10:11 PM, Xuan Wu <fromwheretowhere.service@gmail.com> wrote:
The program's meaning becomes obvious only after all this history study. Yes, but don't forgot that this is not a program (demonstrating usefull behavior), but a sample, demonstrating syntax.
If the code is just demonstrating syntax, something like `dictionary = {'key1':1, 'key2':2}` would be sufficient and leave no room for speculation. That would also make the sample dry and boring, and reader would not learn which real-world use cases a dictionary is typically used in. IMO demonstrating the use case was part of the initial intention, so making the meaning of the use case as clear as possible would be ideal.
It was fun for sure, but IMO most readers won't go that far, as I didn't find any of such explanations online so far. Which is fine, as the example is OK to understand syntax. Understanding what authors had in mind back then while redacting examples is a whole other level of reading.
Frankly my investigation did not aim to understand what Guido had in mind, but to understand what this program was about, which I couldn't have figured out without knowing Guido's past. Like I mentioned, if it were clear that they were arbitrary values, I would have left it be without second thought. At this moment I don't think Guido intended to make the values arbitrary, otherwise he wouldn't have even put his name in it in the first place. My guess is he mainly targeted his colleagues as the first readers of the tutorial, who would easily understand its meaning back then. Though most current readers are fine without knowing all this background info and just treating those values as arbitrary, still I think it's a pity that the code's meaning was buried in history. IMO it'll be more reader-friendly to add footnotes to those classic sample code for better understanding, which the initial author would also appreciate. Best, Xuan.
participants (3)
-
Julien Palard -
Steven D'Aprano -
Xuan Wu