summaryrefslogtreecommitdiffstats
path: root/.md/thoughts/syntax
diff options
context:
space:
mode:
Diffstat (limited to '.md/thoughts/syntax')
-rw-r--r--.md/thoughts/syntax/my-worst-habit.md26
-rw-r--r--.md/thoughts/syntax/random-python-idiosyncrasies.md35
2 files changed, 39 insertions, 22 deletions
diff --git a/.md/thoughts/syntax/my-worst-habit.md b/.md/thoughts/syntax/my-worst-habit.md
index 2f760e1..ab89ddf 100644
--- a/.md/thoughts/syntax/my-worst-habit.md
+++ b/.md/thoughts/syntax/my-worst-habit.md
@@ -39,18 +39,26 @@ men take these noxious substances and go into convulsive states. Their
twitchings and mutterings are thought to have prophetic significance.")
```
-This is the only example I know that dares to put parentheses within
-parentheses, unless we're counting math textbooks. In a way it works,
-since if information is ever *superfluous*, the history of sailors
-getting high on nutmeg fits that bill. An academic reader might easily
-pick up on that, but to everyone else, I think a full paragraph of text
-in parentheses signals the reader to scroll down in the hopes that the
-story continues.
+This is the only example I know that dares to put parentheses *and* a
+long quote within parentheses, unless we're counting math textbooks.
+In a way it works, since if information is ever *superfluous*, the
+history of sailors getting high on nutmeg fits that bill. A careful
+reader might easily pick up on that, but to everyone else, I think a
+full paragraph of text in parentheses signals the reader to scroll
+down in the hopes that the story continues.
But just in case you think I'm just picking on William S.
-Burroughs, here's an example I regrettably wrote to a ... recently:
+Burroughs, here's an example I regrettably wrote to a coworker
+recently with some details removed:
-...
+```
+[...] As a precaution, I did review $NOBODY's recent
+$THING_I_WAS_ASKED_TO_REVIEW (if you would like a detailed report on
+that, I can pull that together for you).
+```
+
+Somehow, I managed to take the *one* point worth emphasizing (an entire
+sentence at that!) and *de*-emphasized it.
It's a habit I can't break. So please, if you are a caring reader, do
complain when I overuse parentheses. I deserve it.
diff --git a/.md/thoughts/syntax/random-python-idiosyncrasies.md b/.md/thoughts/syntax/random-python-idiosyncrasies.md
index be3f1f8..22e9e25 100644
--- a/.md/thoughts/syntax/random-python-idiosyncrasies.md
+++ b/.md/thoughts/syntax/random-python-idiosyncrasies.md
@@ -1,16 +1,24 @@
# Coding Style Guide
The purpose of this document is twofold:
+
1) To ensure that anyone who might like to make my code better understands
- why I write python the way I do
-2) to ensure *I* adhere to my own style because I'm terribly inconsistent
+ why I write python the way I do
+2) To ensure *I* adhere to my own style because I'm terribly inconsistent
Being terribly inconsistent, the guidelines are not set in stone and if
you have a good argument for doing things a particular, I don't really care.
*BUT* first and foremost, *code must comply with PEP8 first*. This is easy
-to automate. I like coala since it's friendly but there' plenty of advanced
-linters out there.
+to automate. I like [black](https://pypi.org/project/black/) since it's
+easy to use but there' plenty of advanced linters out there.
+
+I usually invoke it like this to turn off forcing double quotes and
+force the line length to 72:
+
+```bash
+black -S -l 72 file.py
+```
That aside, I have the following idiosyncracies:
@@ -21,7 +29,7 @@ why not?
Like so:
-```code
+```python
string = "This is a phrase"
word = "word"
cur_char = 'a'
@@ -33,7 +41,7 @@ dictionary = { 'key' "1245dqw3w431", 'return': newline }
The only exception is for strings with quotes in them (anything to avoid
escapes, really)
-```code
+```python
quoted_string = (
'"You miss 100% of the shots you don't take - Wayne Gretsky"'
' - Michael Scott'
@@ -45,7 +53,8 @@ That brings me to my next point.
## 2) Long strings belong in parentheses
As in:
-```code
+
+```python
longboi = (
"This is a really long string usefull when making help menus. Be\n"
"sure to leave s space at the end of each line, or add a new line\n"
@@ -55,7 +64,7 @@ longboi = (
)
```
-## 3) Tabs are four spaces and spaces are *ALWAYS* prefered to tabs
+## 3) Tabs are four spaces and spaces are *ALWAYS* preferred to tabs
Again, see PEP8.
@@ -63,19 +72,19 @@ Again, see PEP8.
It's a pain to read:
-```code
+```python
1/(2*sqrt(pi))*exp(x**2)
```
Do this
-```code
+```python
1 / (2 * sqrt(pi)) * exp(x ** 2)
```
The same goes for logic operators
-```code
+```python
true & false ^ true
```
@@ -85,7 +94,7 @@ This is python. Unless there's a compatibility thing (like a library's
code was written that way, or it matches an API variable), snake_case
is preferred.
-```code
+```python
user_input = int(input()) # variable
MAX_INPUT = 1000 # constant
def judge_input(_input, _max): # function
@@ -99,7 +108,7 @@ class Input_Judger: # a class
Example exception:
-```code
+```python
# this doesn't actually work, but you get the idea
r = requests.get("www.debian.org")
pageSize = r.json()['pageSize'] # camel case ok