My name is David and I like to sail. I worked at a sailing school teaching dinghy sailing for a few years (see below for a picture).
I taught kids to sail several different boats while I was a sailing instructor.
I also enjoy other activities:
Random Caps (.py) I wrote this script to randomly capitalize characters in a text file. Iām not sure whether there are any uses for this but it was a fun exercise. The code is below.
import numpy.random as random
# Define constants
= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
UPPER = "abcdefghijklmnopqrstuvwxyz"
LOWER
def main(file_in: str, file_out: str = "./rand_caps.txt"):
"""
Takes an input text file and randomly capitalizes the letters in it.
Writes the output to another text file.
:param file_in: Path to a text file containing letters to randomly capitalize
:param file_out: Path to a text file to write the new letters in
Default: `./rand_caps.txt`
"""
= open(file_in, "r")
file_input = []
char_list # Collect all the ASCII characters
for line in file_input:
for character in line:
char_list.append(character)
file_input.close()= open(file_out, 'w')
output_file # Go through and randomly capitalize them
for character in char_list:
# Pick whether to change it
= random.randint(0, 2)
change_char # Change it from upper to lower or vice-versa
if change_char == 1 and character in UPPER:
output_file.write(character.lower())elif change_char == 1 and character in LOWER:
output_file.write(character.upper())else:
output_file.write(character)
output_file.close()
if __name__ == "__main__":
import argparse
= argparse.ArgumentParser()
p "file", help="The file to read in letters from")
p.add_argument("-o", "--out", nargs="?", default="./rand_caps.txt", help="Path to a file to hold the output")
p.add_argument(= p.parse_args()
args
file, args.out) main(args.