Package: paragraphs
paragraphsIncorporate long strings painlessly, beautifully into Python code.ExamplesEasily edited,gq-able,fill-paragraph-able, comprehensive error messages.fromparagraphsimportparclassSuddenDeathError(Exception):def__init__(self,cause:str)->None:self.cause=causedef__str__(self):returnpar(f"""Y - e - e - e - es, Lord love you! Why should she die of{self.cause}? She come through diphtheria right enough the yearbefore. I saw her with my own eyes. Fairly blue with it, she was.They all thought she was dead; but my father he kept ladling gindown her throat till she came to so sudden that she bit the bowloff the spoon.What call would a woman with that strength in her have to die of{self.cause}?  What become of her new straw hat that should havecome to me? Somebody pinched it; and what I say is, them as pinchedit done her in.""")raiseSuddenDeathError("influenza")Nicely-formatted long string data. Spoilers for some old novels here,
but these ARE the original titles.author2titles={"Samuel Penhallow":[par("""The history of the wars of New-England with the Eastern Indians;or, a narrative of their continued perfidy and cruelty, from the10th of August, 1703, to the peace renewed 13th of July, 1713. Andfrom the 25th of July, 1722, to their submission 15th December,1725, which was ratified August 5th, 1726""")],"Daniel Defoe":[par("""The Life and Strange Surprizing Adventures of Robinson Crusoe, OfYork, Mariner: Who lived Eight and Twenty Years, all alone in anun-inhabited Island on the Coast of America, near the Mouth of theGreat River of Oroonoque; Having been cast on Shore by Shipwreck,wherein all the Men perished but himself. With An Account how hewas at last as strangely deliver'd by Pyrates"""),par("""The Fortunes and Misfortunes of the Famous Moll Flanders Who wasborn in Newgate, and during a life of continu’d Variety forThreescore Years, besides her Childhood, was Twelve Years a Whore,five times a Wife (whereof once to her brother) Twelve Years aThief, Eight Years a Transported Felon in Virginia, at last grewRich, liv’d Honest and died a Penitent"""),],}InstallationpipinstallparagraphsUsefromparagraphsimportparPARAGRAPH=par("""Lorem ipsum dolor sit amet, consectetur adipiscing elit, seddo eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim adminim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip exea commodo consequat. Duis aute irure dolor in reprehenderit in voluptatevelit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecatcupidatat non proident, sunt in culpa qui officia deserunt mollit anim idest laborum.""")# the above is equivalent toPARAGRAPH=("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod"" tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim"" veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea"" commodo consequat. Duis aute irure dolor in reprehenderit in voluptate"" velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint"" occaecat cupidatat non proident, sunt in culpa qui officia deserunt"" mollit anim id est laborum.")FeaturesJoins lines. Removes indentation and leading whitespace.fromparagraphsimportparpar('''Lorem ipsum dolorsit amet,''')# yieldsLoremipsumdolorsitamet,Separates paragraphs with double newline ('\n\n').fromparagraphsimportparpar'''Lorem ipsum dolorsit amet,consecteturadipiscingelit'''# yieldsLoremipsumdolorsitamet,<blankline>consecteturadipiscingelitRetains one trailing newline (if present).>>>par('''retains one trailing newline... ''')retainsonetrailingnewline<blankline>>>>par('''no trailing newline''')notrailingnewlineNotesconverts all whitespace to " ">>>par('''converts\tall\twhitespace\tto\<space>''')convertsallwhitespaceto<space>compresses consecutive whitespace to " ">>>par('''compresses       consecutive    whitespace''')compressesconsecutivewhitespace