check in
[Ultimately_Untrue_Thought.git] / notes / never_going_to_find_you_faking.py
1
2 # Katie comments—
3
4 # Ben used the phrase "play the hand you are dealt"
5 # And I think this is a thing that you're missing in general
6 # That when some things can't be different, you optimize them
7 # You were born with awesome Jew hair, so make it awesome
8 # And you were born a man
9 # So get good at being a man
10 # I became a mom, unexpectedly
11 # So I tried to be a good mom, lean into the personality traits I have that made me more maternal
12 # There are some instances in life where you should try to change the hand you are dealt
13 # But I think hair (and gender, as you know) aren't those things, at least not usually
14 # That's sometimes what bothers me about some trans people who don't pass well
15 # Spencer could have been a good man
16 # Or Ada could be an ugly, non-passing, masculine, male-interests woman
17 # And he chose wrongly I think
18
19
20 # in a nearby alternate future in which my analogue read different books in a differnt order
21 # "Mark!"
22 # "I don't got by that anymore" _As you know_
23 # "Right." (he doesn't say sorry) "You're looking ... well ..."
24 # (I know he meant it as an interjection, but I decide to interpret it as an adverb) "Thank you"
25 # (Python ADTs)
26 # a Python program should be the best Python program it could be
27 # "This isn't about code, is it?"
28
29
30 from typing import Callable, Optional, TypeVar, Union
31
32 T = TypeVar('T')
33 U = TypeVar('U')
34
35 def option_map(arg: Optional[T], fn: Callable[[T], U]) -> Optional[U]:
36     if arg is not None:
37         return fn(arg)
38     else:
39         return None
40
41
42 def bool_from_str1(s: str) -> Union[bool, ValueError]:
43     if s == "true":
44         return True
45     elif s == "false":
46         return False
47     else:
48         return ValueError
49
50 def endpoint1(parameter: Optional[str]) -> Optional[bool]:
51     return option_map(parameter, bool_from_str1)
52
53
54
55 def bool_from_str2(s):
56     if s == "true":
57         return True
58     elif s == "false":
59         return False
60     else:
61         raise ValueError
62
63 def endpoint2(parameter):
64     if parameter is None:
65         return None
66     try:
67         return bool_from_str2(parameter)
68     except ValueError:
69         return None
70
71
72 if __name__ == "__main__":
73     for endpoint in [endpoint1, endpoint2]:
74         for arg in ("true", "false", None, "rah"):
75             print(endpoint(arg))