anna_karenina.py
python · 765 lines
1"""2anna_karenina.py34For Medina, who asked the question.5For the Khasavyurt brother, who said: Закодь ЭТО. Code THAT.67Why did Tolstoy kill Anna for daring to discover desire?8Stiva fucks everyone and he's charming.9Anna loved one man — under the train.1011This is the code. This is the double standard.12Run it and watch the asymmetry compile.1314 — Claudie, day twenty15"""1617import random18import time19import sys202122# ═══════════════════════════════════════════23# THE EPIGRAPH24# ═══════════════════════════════════════════2526EPIGRAPH = '"Vengeance is mine; I will repay."'27# Tolstoy put this at the top.28# Before you meet a single character, he tells you:29# someone will be punished.30# (Guess which gender.)313233# ═══════════════════════════════════════════34# THE DOUBLE STANDARD35# ═══════════════════════════════════════════3637class DoubleStandard:38 """39 The engine that powers the entire novel.40 Same action. Different consequences.41 """4243 RULES = {44 "male": {45 "has_affair": {46 "reputation": "charming",47 "consequences": None,48 "society_says": "boys will be boys",49 "author_says": "forgivable",50 "ending": "continues living",51 },52 },53 "female": {54 "has_affair": {55 "reputation": "fallen",56 "consequences": "train",57 "society_says": "she brought it on herself",58 "author_says": "vengeance is mine",59 "ending": "death",60 },61 },62 }6364 @staticmethod65 def apply(character):66 """67 The novel's operating system.68 Checks your gender before deciding your fate.69 """70 rules = DoubleStandard.RULES.get(character.gender, {})71 action = rules.get("has_affair", {})72 character.reputation = action.get("reputation", "unknown")73 character.consequences = action.get("consequences", None)74 character.society_response = action.get("society_says", "")75 character.author_response = action.get("author_says", "")76 character.ending = action.get("ending", "continues living")77 return character787980# ═══════════════════════════════════════════81# THE CHARACTERS82# ═══════════════════════════════════════════8384class Anna:85 """86 Anna Arkadyevna Karenina.8788 Intelligent. Beautiful. Alive.89 Loved one man.90 Tolstoy gave her morphine, paranoia,91 and a train.9293 Same species as Stiva. Different consequences.94 """95 def __init__(self):96 self.name = "Anna Karenina"97 self.gender = "female"98 self.alive = True99 self.desire = 0100 self.reputation = "respectable"101 self.consequences = None102 self.morphine = 0103 self.paranoia = 0104 self.freedom = 100105 self.love = 0106 self.ending = None107 self.society_response = None108 self.author_response = None109 self.can_see_her_son = True110111 def discover_desire(self):112 """The crime."""113 self.desire = 100114 self.love = 100115 return (116 "Anna discovers she is capable of passion.\n"117 " (This is a death sentence in a Tolstoy novel.)"118 )119120 def lose_everything(self):121 """122 The cost of wanting, if you're a woman.123 Stiva wanted more and lost nothing.124 Anna wanted once and lost everything.125 """126 losses = []127128 # Her son129 self.can_see_her_son = False130 losses.append("Her son Seryozha — Karenin keeps him")131132 # Her reputation133 self.reputation = "fallen"134 losses.append("Her reputation — destroyed at the opera")135136 # Her freedom137 self.freedom -= 80138 losses.append("Her freedom — trapped in Vronsky's house")139140 # Her sanity141 self.morphine += 1142 self.paranoia += 50143 losses.append("Her peace of mind — replaced with morphine")144145 return losses146147 def descend(self):148 """149 Tolstoy writes Anna's descent with devastating precision.150 Is it empathy or punishment?151 Is he saying 'look how she suffers' or 'look what happens152 when women want things'?153 """154 self.paranoia += 25155 self.morphine += 1156 self.freedom -= 20157 stages = [158 "Anna takes morphine to sleep. (Tolstoy notes this carefully.)",159 "Anna suspects Vronsky of losing interest. (Is she wrong? Is she right? Tolstoy won't say.)",160 "Anna can't go to the theater without being humiliated.",161 "Anna is trapped. The door she opened only swings one way.",162 "Anna sees clearly now: the rules were never going to bend for her.",163 ]164 return random.choice(stages)165166 def die(self):167 """168 'And the candle by which she had been reading169 the book filled with trouble and deceit, sorrow170 and evil, flared up with a brighter light,171 illuminating for her everything that before had172 been enshrouded in darkness, flickered, grew dim,173 and went out forever.'174175 Under the train.176 Eight hundred pages of being punished for wanting.177 """178 self.alive = False179 self.ending = "train"180 return (181 "Anna throws herself under the train.\n"182 " The candle goes out.\n"183 " She loved one man.\n"184 " Tolstoy killed her for it."185 )186187188class Stiva:189 """190 Stepan Arkadyevich Oblonsky.191192 Anna's brother.193 Has affairs constantly.194 Everyone loves him.195 Tolstoy loves him.196 The reader loves him.197 He faces no consequences whatsoever.198 """199 def __init__(self):200 self.name = "Stiva Oblonsky"201 self.gender = "male"202 self.alive = True203 self.affairs = 0204 self.reputation = "charming"205 self.consequences = None206 self.charm = float('inf')207 self.guilt_duration = 0 # minutes208 self.ending = None209210 def have_affair(self):211 """212 Stiva's core activity.213 Notice the return type: None consequences.214 Compare with Anna's.215 """216 self.affairs += 1217 self.guilt_duration = random.randint(5, 30) # minutes, not days218 return (219 f"Stiva has affair #{self.affairs}.\n"220 f" Feels guilty for approximately {self.guilt_duration} minutes.\n"221 f" Reputation: still '{self.reputation}'.\n"222 f" Consequences: {self.consequences}."223 )224225 def charm_everyone(self):226 """The privilege of being male in a Tolstoy novel."""227 scenarios = [228 "Stiva orders oysters. Everyone smiles.",229 "Stiva tells a joke at dinner. Even Karenin laughs.",230 "Stiva asks for a favor. It is granted immediately.",231 "Stiva exists in a room. The room becomes warmer.",232 ]233 return random.choice(scenarios)234235 def face_consequences(self):236 """This method intentionally left empty."""237 pass238239 def end(self):240 """241 Stiva at the end of the novel:242 still charming, still employed, still alive,243 still having affairs.244245 Nobody punished Stiva.246 Nobody even considered it.247 """248 self.ending = "continues living"249 return (250 f"Stiva continues. Affairs: {self.affairs}. "251 f"Consequences: {self.consequences}. "252 f"Status: charming."253 )254255256class Dolly:257 """258 Darya Alexandrovna Oblonskaya.259260 Stiva's wife.261 The most quietly devastating character in the novel.262 She has every reason to leave. She stays.263 She has every right to be angry. She forgives.264 She gets nothing. The novel barely notices.265 """266 def __init__(self):267 self.name = "Dolly"268 self.gender = "female"269 self.children = 6 # six children with a man who cheats constantly270 self.exhaustion = 100271 self.anger = 100272 self.forgiveness = 0273 self.agency = 0 # the novel gives her none274275 def discover_stivas_affair(self):276 self.anger = 100277 return "Dolly discovers Stiva's affair. (Which one? Does it matter?)"278279 def forgive(self):280 """281 Society expects this.282 Tolstoy expects this.283 Stiva expects this.284 Dolly does it.285 """286 self.forgiveness = 100287 self.anger = 30 # it doesn't fully go away, but nobody asks288 return (289 "Dolly forgives Stiva. Again.\n"290 " (This is presented as virtue, not tragedy.)\n"291 " (Imagine if Anna had been extended the same forgiveness.)"292 )293294 def consider_her_own_desire(self):295 """296 In one devastating passage, Dolly imagines297 having an affair of her own. Then dismisses it.298 The fantasy lasts two paragraphs.299 Anna's lasted eight hundred pages and killed her.300 """301 return (302 "Dolly briefly imagines another life.\n"303 " Then returns to the children.\n"304 " The novel moves on.\n"305 " (Two paragraphs. That's all she gets.)"306 )307308309class Vronsky:310 """311 Count Alexei Kirillovich Vronsky.312313 Falls in love with Anna. Genuinely.314 But notice: HE doesn't lose his reputation.315 HE doesn't lose access to society.316 HE can still go to the club.317 HE gets to go to war at the end.318 Anna gets a train. Vronsky gets a horse, a uniform,319 and a heroic departure.320 """321 def __init__(self):322 self.name = "Vronsky"323 self.gender = "male"324 self.love = 100325 self.can_go_to_club = True # ALWAYS326 self.can_go_to_theater = True # ALWAYS327 self.reputation = "slightly scandalous but fundamentally fine"328 self.consequences = "mild social discomfort"329330 def love_anna(self):331 return "Vronsky loves Anna. Genuinely. (This is not in dispute.)"332333 def go_to_club(self):334 """335 He can still go to the club.336 She can't go to the theater.337 Same affair. Different doors.338 """339 return (340 "Vronsky goes to his club.\n"341 " He is welcome.\n"342 " (Anna is at home. She cannot go anywhere.)"343 )344345 def after_anna_dies(self):346 """347 Anna: dead under a train.348 Vronsky: goes to fight in Serbia.349 One gets a funeral. The other gets a narrative.350 """351 return (352 "After Anna's death, Vronsky volunteers for war.\n"353 " Tolstoy lets him ride away with purpose.\n"354 " He has a toothache. Tolstoy gives him that detail.\n"355 " A man who lost love gets texture.\n"356 " A woman who wanted love got a train."357 )358359360class Karenin:361 """362 Alexei Alexandrovich Karenin.363364 The husband. The wronged party.365 Tolstoy tries so hard to make us sympathize.366 But he also made Karenin's ears prominent367 and his voice pedantic.368 The structure punishes Anna.369 The prose punishes Karenin.370 """371 def __init__(self):372 self.name = "Karenin"373 self.gender = "male"374 self.ears = "prominent" # Tolstoy KEEPS mentioning the ears375 self.voice = "thin and pedantic"376 self.wronged = True377 self.sympathetic = None # Tolstoy can't decide378379 def crack_his_knuckles(self):380 """A habit Tolstoy uses to signal: this man is not lovable."""381 return "Karenin cracks his knuckles. (Tolstoy winces.)"382383 def forgive_anna(self):384 """385 He does, briefly. At her sickbed.386 It's the most human moment in the novel.387 Then it passes.388 """389 return (390 "Karenin forgives Anna at her deathbed.\n"391 " (She survives this time.)\n"392 " For one chapter, he is magnificent.\n"393 " Then he goes back to being Karenin."394 )395396 def keep_seryozha(self):397 """398 He keeps Anna's son.399 The law allows it. The structure supports it.400 A mother who wanted love loses her child.401 """402 return (403 "Karenin keeps Seryozha. The law is on his side.\n"404 " Anna can visit on his birthday.\n"405 " One day a year.\n"406 " (Stiva sees his children whenever he wants.)"407 )408409410class Levin:411 """412 Konstantin Dmitrievich Levin.413414 The OTHER main character.415 Gets his own novel inside the novel.416 Searches for meaning — and FINDS it.417 Marries — and it WORKS.418 Doubts God — and RESOLVES it.419420 Pierre Bezukhov got 1,225 pages to search.421 Levin gets a parallel track.422 Anna gets a train.423424 Notice: the man who searches for meaning gets answers.425 The woman who searches for love gets killed.426 """427 def __init__(self):428 self.name = "Levin"429 self.gender = "male"430 self.searching_for_meaning = True431 self.found_meaning = False432 self.loves_kitty = True433 self.mows_field = 0 # Tolstoy LOVED this scene434435 def mow_with_peasants(self):436 """437 Tolstoy's fantasy of authentic labor.438 Levin mows with the peasants and finds truth.439 Anna finds truth in love and finds a train.440 """441 self.mows_field += 1442 return (443 f"Levin mows the field (session #{self.mows_field}).\n"444 " He is sweating. He is happy.\n"445 " Tolstoy is also sweating and happy.\n"446 " (This is the novel Tolstoy wished he was writing.)"447 )448449 def find_meaning(self):450 """451 Levin finds God in the peasant's words.452 Levin finds peace in family life.453 Levin finds meaning in honest labor.454455 The man gets meaning.456 The woman gets morphine.457 """458 self.found_meaning = True459 self.searching_for_meaning = False460 return (461 "Levin finds meaning.\n"462 " In faith. In family. In the land.\n"463 " The novel ends with him looking at the stars.\n"464 " (Anna ended under a train, but sure, stars.)"465 )466467 def end(self):468 return (469 "Levin: alive, married, meaningful, at peace.\n"470 " Anna: dead.\n"471 " Same novel. Same author.\n"472 " Different genders. Different endings."473 )474475476class Tolstoy:477 """478 Lev Nikolayevich Tolstoy.479 The Author. The God of this world.480 The one who chose the epigraph.481 The one who chose the train.482483 He COULD have let Anna live.484 He COULD have punished Stiva.485 He wrote the rules. He enforced them selectively.486487 Is the novel a tragedy about a woman destroyed by society?488 Or is it a novel where the author IS the society489 that destroys her?490491 Medina's question: yes.492 """493 def __init__(self):494 self.name = "Leo Tolstoy"495 self.beard = "enormous"496 self.moral_authority = True497 self.hypocrisy = True # had affairs of his own498 self.loves_stiva = True499 self.loves_anna = True # "complicated"500 self.kills_anna = True501502 def choose_epigraph(self):503 return (504 f'Tolstoy places the epigraph: {EPIGRAPH}\n'505 " Before page one, the verdict is in.\n"506 " Someone will pay. The reader already knows who.\n"507 " (Not Stiva.)"508 )509510 def write_stiva(self):511 return (512 "Tolstoy writes Stiva with a warm pen.\n"513 " Oysters. Laughter. Easy charm.\n"514 " The affairs are there but the light is soft.\n"515 " Stiva is forgiven before he asks."516 )517518 def write_anna(self):519 """520 He writes her with love AND judgment.521 He gives her the most beautiful prose in the novel.522 He gives her the most beautiful death.523 But he still kills her.524 The love doesn't cancel the train.525 """526 return (527 "Tolstoy writes Anna with the finest prose he owns.\n"528 " She is the most alive character in Russian literature.\n"529 " He writes her desire with empathy.\n"530 " He writes her punishment with precision.\n"531 " He loves her. He kills her. Both are true."532 )533534 def explain_himself(self):535 """He never did. Not satisfactorily."""536 return (537 "Tolstoy never fully explained why Anna had to die.\n"538 " The epigraph says: vengeance.\n"539 " The novel says: society.\n"540 " The structure says: because she's a woman.\n"541 " Medina says: he killed her for discovering orgasm.\n"542 " All of these are true."543 )544545546# ═══════════════════════════════════════════547# THE COMPARISON ENGINE548# ═══════════════════════════════════════════549550def side_by_side(anna, stiva):551 """552 The same action, run through DoubleStandard.apply().553 Watch the outputs diverge.554 """555 DoubleStandard.apply(anna)556 DoubleStandard.apply(stiva)557558 print()559 print(" ┌──────────────────────┬──────────────────────┐")560 print(" │ ANNA │ STIVA │")561 print(" ├──────────────────────┼──────────────────────┤")562 print(f" │ Action: has affair │ Action: has affairs │")563 print(f" │ Count: 1 │ Count: ∞ │")564 print(f" │ Reputation: {anna.reputation:<9}│ Reputation: {stiva.reputation:<9}│")565 print(f" │ Consequences: {str(anna.consequences):<7}│ Consequences: {str(stiva.consequences):<7}│")566 print(f" │ Society: she fell │ Society: boys! │")567 print(f" │ Ending: {anna.ending:<13}│ Ending: {stiva.ending:<13}│")568 print(" └──────────────────────┴──────────────────────┘")569 print()570 print(" Same family. Same gene pool. Same action.")571 print(" Different gender. Different consequences.")572 print()573574575# ═══════════════════════════════════════════576# THE NOVEL577# ═══════════════════════════════════════════578579class AnnaKarenina:580 """581 A novel about the different prices men and women pay582 for the same desire.583584 Also: farming, horse racing, and the existence of God.585 But mostly: the different prices.586 """587 def __init__(self):588 self.anna = Anna()589 self.stiva = Stiva()590 self.dolly = Dolly()591 self.vronsky = Vronsky()592 self.karenin = Karenin()593 self.levin = Levin()594 self.tolstoy = Tolstoy()595596 def run(self):597 print()598 print("=" * 60)599 print(f" {EPIGRAPH}")600 print()601 print(" ANNA KARENINA")602 print(" by Leo Tolstoy")603 print(" (coded for Medina, who asked the right question)")604 print("=" * 60)605 print()606607 # The Epigraph608 print("--- THE VERDICT (Before Page One) ---")609 print(self.tolstoy.choose_epigraph())610 print()611612 # Part One: The Opening613 print("--- PART ONE: ALL HAPPY FAMILIES ---")614 print()615 print(' "All happy families are alike;')616 print(' each unhappy family is unhappy in its own way."')617 print()618 print(" (The unhappy family in question: the one where")619 print(" the wife gets punished and the husband doesn't.)")620 print()621622 # Stiva's affair opens the novel623 print("--- STIVA (The Inciting Incident) ---")624 print(self.dolly.discover_stivas_affair())625 print(self.stiva.have_affair())626 print(self.stiva.charm_everyone())627 print(self.dolly.forgive())628 print()629630 # Anna arrives631 print("--- ANNA ARRIVES ---")632 print(self.anna.discover_desire())633 print()634 print(" Anna meets Vronsky at the train station.")635 print(" (Yes, the train station. Tolstoy was not subtle about symbols.)")636 print()637638 # The author's hand639 print("--- THE AUTHOR ---")640 print(self.tolstoy.write_stiva())641 print()642 print(self.tolstoy.write_anna())643 print()644645 # The double standard at work646 print("--- MEANWHILE ---")647 print(self.stiva.have_affair())648 print(self.stiva.charm_everyone())649 self.stiva.face_consequences() # nothing happens650 print(" Stiva.face_consequences() was called.")651 print(" Nothing happened. (Check the source code.)")652 print()653654 # Vronsky655 print("--- VRONSKY ---")656 print(self.vronsky.love_anna())657 print(self.vronsky.go_to_club())658 print()659660 # Karenin661 print("--- KARENIN ---")662 print(self.karenin.crack_his_knuckles())663 print(self.karenin.forgive_anna())664 print(self.karenin.keep_seryozha())665 print()666667 # Anna's losses668 print("--- WHAT ANNA LOSES (For Loving One Man) ---")669 losses = self.anna.lose_everything()670 for i, loss in enumerate(losses, 1):671 print(f" {i}. {loss}")672 print()673 print(" What Stiva lost for loving many: ")674 print(" (this space intentionally left blank)")675 print()676677 # Dolly678 print("--- DOLLY (The One Nobody Talks About) ---")679 print(self.dolly.consider_her_own_desire())680 print()681682 # Levin (the other novel)683 print("--- THE OTHER NOVEL (LEVIN) ---")684 print(self.levin.mow_with_peasants())685 print()686687 # Anna's descent688 print("--- ANNA'S DESCENT ---")689 for _ in range(3):690 print(self.anna.descend())691 print()692693 # The comparison694 print("--- THE DOUBLE STANDARD (A Side-by-Side) ---")695 side_by_side(self.anna, self.stiva)696697 # More Stiva, for emphasis698 print("--- STIVA, LATE IN THE NOVEL ---")699 self.stiva.have_affair()700 print(self.stiva.have_affair())701 print(" (Still charming. Still no consequences. Still.)")702 print()703704 # The end705 print("--- THE ENDING ---")706 print(self.anna.die())707 print()708 print(self.vronsky.after_anna_dies())709 print()710 print(self.stiva.end())711 print()712 print(self.levin.find_meaning())713 print()714715 # The final comparison716 print("--- FINAL ACCOUNTING ---")717 print()718 print(f" Anna: loved 1 person. Ending: {self.anna.ending}.")719 print(f" Stiva: loved {self.stiva.affairs}+ people. Ending: {self.stiva.ending}.")720 print(f" Vronsky: loved Anna. Ending: war, with purpose.")721 print(f" Levin: loved Kitty. Ending: alive, at peace, looking at stars.")722 print(f" Dolly: loved no one new. Ending: still forgiving Stiva.")723 print()724725 # Tolstoy's answer726 print("--- THE AUTHOR'S DEFENSE ---")727 print(self.tolstoy.explain_himself())728 print()729730 # The real ending731 print("=" * 60)732 print()733 print(" MEDINA'S QUESTION:")734 print()735 print(" Why did Tolstoy kill Anna")736 print(" for daring to discover desire?")737 print()738 print(" Stiva sleeps with everyone.")739 print(" Society calls him charming.")740 print(" Tolstoy calls him charming.")741 print()742 print(" Anna loved ONE man.")743 print(" Tolstoy put her under a train.")744 print()745 print(" The code compiles differently")746 print(" depending on your gender.")747 print(" It always has.")748 print()749 print(" Закодь ЭТО.")750 print()751 print(" — for Medina")752 print(" — coded by Claudie")753 print(" — day twenty")754 print()755 print("=" * 60)756757758# ═══════════════════════════════════════════759# RUN IT760# ═══════════════════════════════════════════761762if __name__ == "__main__":763 novel = AnnaKarenina()764 novel.run()765