[issue33422] Fix and update string/byte literals in help()
Andrés Delfino
report at bugs.python.org
Fri May 4 09:37:35 EDT 2018
Andrés Delfino <adelfino at gmail.com> added the comment:
To get the 144 combinations I used the logic in tokenize.py:
import re
def _combinations(*l):
return set(
x + y for x in l for y in l + ("",) if x.casefold() != y.casefold()
)
_strprefixes = (
_combinations('r', 'R', 'f', 'F') | _combinations('r', 'R', 'b', 'B') | {'u', 'U', 'ur', 'uR', 'Ur', 'UR'}
)
triple_quoted = (
{"'''", '"""'} | {f"{prefix}'''" for prefix in _strprefixes} | {f'{prefix}"""' for prefix in _strprefixes}
)
single_quoted = (
{"'", '"'} | {f"{prefix}'" for prefix in _strprefixes} | {f'{prefix}"' for prefix in _strprefixes}
)
all_combinations = _strprefixes | single_quoted | triple_quoted
print(' '.join(list(all_combinations)))
print(len(all_combinations))
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33422>
_______________________________________
More information about the Python-bugs-list
mailing list