I am working on a python project and below is what I have:
mystring= 'Hello work'
and I want to write a function that replaces k
with a m
some thing like below:
def replace_alpha(string):
return string.replace('k', 'm') # returns Hello worm
I wanted to use Monkey Patching
on a string
such that I can use it the below way:
string = 'Hello work'
string = string.replace_alpha()
print(string) # prints Hello worm
instead of:
string = replace_alpha(string)
is this possible? Can I use monkey patching with a built-in rather can I extent the __builtins__
?