This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from typing import ( | |
List, | |
Dict, | |
Callable, | |
Union, | |
) | |
import numpy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def first_non_whitespace_index(lineText): | |
''' Find the index of the first non-whitespace character on line. ''' | |
pat = re.compile(r'(\s*)(\S)') | |
m = pat.match(lineText) | |
if m: | |
# start(2) gets start of 2nd group | |
return m.start(2) | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
USAGE: | |
Let's say you have a "find_words_with_letter" function (not method) in a script called "script_name.py"... | |
def find_words_with_letter(fileName, letter = "g"): | |
#fxn code here | |
...you can then call the function in the script from the command line - function name 1st argument, function args follow. |