<jupyter_start><jupyter_text>string module is different form string type(***str***)this notebook will focus on string module, the similarity and difference will be highlighted when necensary.<jupyter_code>print(type('ass'))
print(type(string))<jupyter_output><class 'str'>
<class 'module'><jupyter_text>string  string constants<jupyter_code>string.ascii_letters
string.punctuation<jupyter_output><empty_output><jupyter_text>string.Formater The Formatter class implements the same layout specification language as the format() method of str. Its features include type coersion, alignment, attribute and field references, named and positional template arguments, and type-specific formatting options. Most of the time the format() method is a more convenient interface to these features, ***but Formatter is provided as a way to build subclasses, for cases where variations are needed.***  str format This is very similar to old styple 'printf', with the addition of the {} support<jupyter_code>'{0} {1} {2}'.format('a','b','c')<jupyter_output><empty_output><jupyter_text>string Tempalte instead of normal %-based substitution, Tempaltes support $-based sustitutions, using the following rule:* $$ is an escapte, replace single $.* `identifier names a sustitution placeholder matching a mapping key of 'identifer.`* ${identifier} is equivalent to $identifier. It is required when valid identifier characters follow the placeholder but are not part of the placeholder, such as "${noun}ification".<jupyter_code>from string import Template
s = Template('$who likes $what')
s.substitute(who='tim', what='kung pao')<jupyter_output><empty_output><jupyter_text>string Helper functions<jupyter_code>string.capwords("hello string")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.096, 'fraction_numerical': 0.0017142857142857142, 'mean_word_length': 7.625615763546798, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '546100', 'license': 'Apache-2.0', 'n_tokens_mistral': 481, 'n_tokens_neox': 471, 'n_words': 180, 'path': 'text/string_Text_Constants_and_Templates.ipynb', 'repo_name': 'scotthuang1989/Python-3-Module-of-the-Week', 'size': '1750'}