Created
May 16, 2020 20:56
-
-
Save ztane/db12bf62982dcc40946c80a10f6ddcf9 to your computer and use it in GitHub Desktop.
Yadayada gettext
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import itertools | |
def ugettext(s): | |
c = itertools.cycle('yada') | |
def replace(m): | |
char = m.group(0) | |
replacement = next(c) | |
if char.isupper(): | |
return replacement.upper() | |
return replacement | |
return re.sub('[a-zA-Z]', replace, s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment