dangerous class neighborhood
avigross at verizon.net
Fri Dec 28 02:01:07 EST 2018
Short answer to a short question.
What does a dot (dot dot) mean in pseudocode?
NOTHING and EVERYTHING.
I think what you see may not be what I wrote. I used three dots in a row (an ellipsis) to mean that something is left out to be filled in with something appropriate.
A = …
B = …
That was meant to mean that it does not really matter exactly what code is used. Set A equal to SOMETHING and set B equal to something.
As it happens, there are computer languages where that is valid code. Python turns out to be one of them!
In python you can often use “pass” in some contexts like:
>>> if 1: pass
>>> def name():
These don’t do anything except serve as a placeholder and should be replaced later. There are cases where you can write something like this:
>>> x = 5
>>> if x > 7:
But although that works, you could simply use a NOT or invert the condition to say:
>>> if not (x > 7):
>>> if (x <= 7):
Well “…” can also be used in modern versions of python although it may not be novice-level material. It can serve as a placeholder in things like this:
>>> def name(x,y,z): pass
Traceback (most recent call last):
File "<pyshell#25>", line 1, in <module>
TypeError: name() missing 1 required positional argument: 'z'
You can see the third positional argument is still the third in this example:
>>> def name(x,y,z): print(x,z)
So what is the middle argument in this case?
>>> def name(x,y,z): print(x,y,z)
1 Ellipsis 3
Ellipsis Ellipsis 3
Ellipsis Ellipsis Ellipsis
I suspect that generally the intent is to eventually fill in the missing argument.
Here is a related anomaly. The single underscore has multiple uses but one is to say you are throwing away something.
>>> a, _, c = (1, "who cares", 3)
But what I used the same variable name multiple times?
>>> _, _, c = (1, "who cares", 3)
To be fair, any variable used repeatedly in that context keeps only the rightmost assignment. But there is an idiom of using just an underscore to mean you don’t care about that and want something else whose name may be made meaningful.
>>> _, _, LastName = ("John", "J.", "Doe")
So, my apologies. I won’t use … even in pseudocode.
From: Abdur-Rahmaan Janhangeer <arj.python at gmail.com>
Sent: Friday, December 28, 2018 12:30 AM
To: Avi Gross <avigross at verizon.net>
Cc: Python <python-list at python.org>
Subject: Re: dangerous class neighborhood
btw what does
A = .
above means? the dot?
http://www.pythonmembers.club <http://www.pythonmembersclub> | https://github.com/Abdur-rahmaanJ
More information about the Python-list