3rd March 2021
Coding⚑
Python⚑
Code Styling⚑
-
Improvement: Don't use try-except to initialize dictionaries.
Instead of:
try: dictionary['key'] except KeyError: dictionary['key'] = {}
Use:
dictionary.setdefault('key', {})
Python Snippets⚑
-
New: Add date management snippets.
-
Get the week number of a datetime:
datetime.datetime(2010, 6, 16).isocalendar()[1]
.
import datetime d = "2013-W26" r = datetime.datetime.strptime(d + '-1', "%Y-W%W-%w")
* Get ordinal from numberimport calendar >> calendar.month_name[3] 'March'
def int_to_ordinal(number: int) -> str: '''Convert an integer into its ordinal representation. make_ordinal(0) => '0th' make_ordinal(3) => '3rd' make_ordinal(122) => '122nd' make_ordinal(213) => '213th' Args: number: Number to convert Returns: ordinal representation of the number ''' suffix = ['th', 'st', 'nd', 'rd', 'th'][min(number % 10, 4)] if 11 <= (number % 100) <= 13: suffix = 'th' return f"{number}{suffix}"
-
Operative Systems⚑
Linux⚑
Vim Plugins⚑
mkdocs⚑
-
New: Document the Navigation object and the on_nav event.
Useful if you develop MkDocs plugins, it holds the information to build the navigation of the site.
Arts⚑
Writing⚑
Grammar and Orthography⚑
-
New: Explain where to add your pronouns.
Hi, I’m Lyz (he/him), I'm writing to tell you…
-
New: Explain when to capitalize after a question mark.
If the sentence ends after the question mark you should capitalize, if it doesn't end, you shouldn't have used the question mark, since it ends a sentence.
Writing Style⚑
-
New: Analyze interesting books on writing style.
- The elements of style by William Strunk Jr and E.B White
- On writing well by William Zinsser
- Bird by bird by Anne Lamott
- On writing by Stephen King
-
New: Explain how to end a letter.
Use Sincerely in doubt and Best if you have more confidence. Add a comma after the sign-off and never use Cheers (it's what I've been doing all my life
(◞‸◟;)
).