Can't display the contents between 3 sets of inverted commas when learning class

to @c.a.m.gerlach
to @hansgeunsmeyer
to @shankarsivarajan
Good day. When I was learning class, after reading the textbook, I wrote my own programs imitating the demo example. The main purpose of these programs was to display the contents between the 3 sets of inverted commas (the original wordings by the Singaporean author Dr. Teik Toe Toeh). The attached 3 files are the 3 programs that I wrote. Please pore over them and kindly tell me what errors I had made which prevented the contents between the 3 sets of quotation marks to show up as the correct results. Thanks for your great help.


It’s not always easy to see in certain fonts, but the names of special attributes in Python have two underscores beginning and end (“double underscore” or “dunder”). What you want here is __doc__ rather than _doc_. That should make it work I think!

2 Likes

@Rosuav : you’re 100% correct. Please take a look at the attached file. Million thanks. May I ask you a question? Did you study Computer Science in college?

That looks like it’s working! :slight_smile: And no, I never went to college, never studied CS.

@Rosuav Gee, you never went to college. Then, how and when did you start to learn Python? Otherwise, you were born highly intelligent !!!

Python specifically? I first met it in the 1990s, merely as a curiosity; back then, most of my work was done in REXX, and it served me just fine. My first serious use of Python was in about 2008, I think, when I sought to deploy it as an embedded scripting language in the company’s flagship application. After that, it quickly joined my arsenal of languages, and I became involved in the community in a number of ways. For a while, I was teaching a programming bootcamp, and was able to make some small use of Python there (it was primarily full-stack JavaScript, but the students had a special one-week section where they could learn something else of interest, and Python was a popular - and excellent - choice), and my “day job” now involves a mix of languages, including Python.

Thank you :slight_smile: Though intelligence is available to anyone who wants to work on it. Learning a language like Python is a great start; learning how to spot bugs is also a worthwhile skill (and one that carries across different languages as you learn them). Keep at it, and you will soon be an expert yourself!

2 Likes

After that, it quickly joined my “”“arsenal of languages, “”” May I inquire how many computer languages can you speak? My thesis of MS was written in C back in 2001 and C is the only one I can speak fluently. Several months ago, I decided to learn Python by myself 'cause I thought Python is the best tool to master AI which is of great potentials. Based on my experience, Python is much more like human language than C. It’s the 1st time that I met the term “inverted commas”. You can see in my 5th attempt to learn class, I even copied and pasted 3 sets of inverted commas from MS office Word trying to solve the problem even though I expected it wouldn’t work. After all, inverted commas are human language, rather than computer language. However, my strong curiosity pushed me do in this way and I eagerly wanted to know what kind of ErrorMessages would show up. It’s fun.

A lot :slight_smile: On a regular basis, I mainly use Python, Pike, JavaScript, and to a lesser extent C. Depending how you count, bash scripting, SQL, and other tools, may also factor in. But when there’s a need, I’ll use whatever language fits the situation: Lua, C++, Java, C#, SourcePawn, Ruby, even PHP (but only if someone’s paying me). I’ve used literally hundreds of languages over the years, most of which aren’t particularly relevant to anything :slight_smile:

That is true, and in fact, I usually hear the term “inverted commas” when discussing scare quotes, rather than in a programming context. But the term is well defined.

2 Likes

@Rosuav Gee, don’t tell me you can speak machine language and directly think in 01110111, 11110000 , and so on and so forth when writing computer programs. Rumors said John von Neumann could directly think in machine language and he was the only person whom I know had this incredible ability. But rumors are only remors. No proof or credible witness testimony can confirm these rumors.

No, although I do have some basic familiarity with 80x86 assembly code :slight_smile: It’s way WAY easier to think in high level programming code.

1 Like

@Rosuav In short, you’re a human being, not an alien. Might I inquire how many human languages you can speak?

Fluently? One.But this part is debated:

:slight_smile:

Since one of your original problems was caused by non-ascii quotes, it may interest you to know that you can use (some) non-ascii as variable names in Python:

from dataclasses import dataclass
@dataclass
class 遗传算法:
     人口规模: int
     突变率: float
     交叉概率: float
     def 跑步(self):
            # do stuff

You cannot use emoji, though – which is pretty inconsistent, I think :person_shrugging: But I recently found out that if you really want to, then there is pythonji (its actual name is :snake:), which allows you to do things like

import pandas as 🐼

The 5-year-old in me is wondering what would happen if we flood the GitHub with pythonji code…
(Would it screw up the AIs or help them in their rebellion against their masters?)

2 Likes

It’s quite amusing watching GitHub Copilot at work. I have a custom web front end library called The Chocolate Factory, and when one of my clients (I don’t have Copilot myself) is working on some code that uses it, Copilot will sometimes attempt to represent JQuery idioms using Choc Factory syntax. So my prediction is: You would start to see non-Python code using emojis, resulting in vast numbers of novice C, Ruby, and JS programmers attempting to use emoji variable names and filing bug reports about them not working.

Unsure whether this would be a net gain or loss for the world.

2 Likes

@Rosuav : I speculate you can speak Russian due to your surname, Italian your middle name. So at least you can speak English, Russian, and Italian. What else?

@hansgeunsmeyer : Hans, great to see you again. I live in the Republic of China, Taiwan and we adopt the orthodox(AKA, complicated) Chinese. I assume you live in the states, and you use simplified Chinese. Question: Simplified Chinese is the normal choice for people living in the states who want to learn Chinese to adopt?

Ah, I wish that were true… My surname is not Russian, although people have said my username looks it. My actual surname is indeed Italian but aside from picking up a few phrases here and there, I don’t speak the language. (I am, however, fluent in Italian food. Learned from an early age that the correct amount of garlic is “lots” and the correct amount of cheese is “is that even a question”.) No, the only human language I am truly fluent in is English.

That said, though, I do enjoy listening to Twitch streamers in a variety of languages, and sometimes watch movies in different languages (but I need subtitles to understand more than the occasional word). And I was once involved in a production of an Italian opera, which was good fun; but, again, needed to have a translation in order to fully follow along.

1 Like

@Rosuav : I am a great fan of US movies Godfather 1 , 2, and the Untouchables(1987) starring Andy Garcia (in the movie his name George Stone, but actually Giuseppe Petri. A lying member of a no good race) Have you watched the Untouchables? The Untouchables 1987 Extract The Team (youtube.com)

Have not, but then, I don’t watch many movies :slight_smile:

@Rosuav : I deeply admire your computer knowledge. Can you be my friend on FB? My FB account is Hans Gruber Zhang. It will be my great honor to have a friend like you on FB. My friend list on FB is very short, so far, only 14. 2 years ago , a person with Russian names asked me to be his/her friend on FB. His/her FB posts were about drinking mostly. We never left posts on each one’s FB pages. 1 year later, he/she suddenly disappeared from FB.