[Question]
  [
In Python, one can save bytes by aliasing functions that are used repeatedly. For example:
```
r=range
a=r(100)
b=r(200)
c=r(300)
```
However, when the functions are member functions together, I don't know how to alias them in a way that allows chaining. For example:
```
s='Hello'
// Plain code
s=s.replace('H','J').replace('e','i').replace('l','m').replace('o','y')
// What I am trying to do
q=replace
s=s.q('H','J').q('e','i').q('l','m').q('o','y')
```
Obviously, what I am trying to do is not valid. And neither is this:
```
q=s.replace
s=q('H','J') // Replaces the 'H' in 'Hello'
s=q('e','i') // Replaces the 'e' in 'Hello'... and the J is gone.
s=q('l','m')
s=q('o','y')
```
Is there a another way to alias member functions and chained functions that saves characters?
  
[Answer]
**No problemo!** You can alias a method, but you have to know how to use it:
```
>>> r=str.replace
>>> a='hello'
>>> r(r(r(r(a,'h','j'),'e','i'),'l','m'),'o','y')
'jimmy'
```
The key is that you have to pass `self` explicitly, because the alias is a kind of function that takes an extra argument that takes `self`:
```
>>> type(r)
<type 'method_descriptor'>
```
[Answer]
Define your own class, with a shorter method name.
For example, if you're using the method `replace()` belonging to the `String` class, you could make your own class `S` have a method called `q` which does the same thing.
Here is one implementation:
```
class m(str):
 def q(a,b,c):return m(a.replace(b,c))
```
Here is a much better implementation:
```
class m(str):q=lambda a,b,c:m(a.replace(b,c))
```
Use it like so:
```
s="Hello"
s=m(s).q('H','J').q('e','i').q('l','m').q('o','y')
```
[Answer]
This is a few characters shorter anyway
```
j=iter('HJeilmoy')
for i in j:s=s.replace(i,next(j))
```
even shorter for a small number of replacements is
```
for i in['HJ','ei','lm','oy']:s=s.replace(*i)
```
of course this just covers one particular case. However code golf is all about finding those special cases that can save you bytes.
It's possible to write a wrapper function that handles the general case, but the code will be too large to have a place in most code golf challenges.
You instead need to think "I can do this transformation efficiently (strokewise) with str.replace. Can I shift the internal representation of my solution to take advantage of that? (without wasting so many strokes to negate the advantage)"
[Answer]
You may use the `reduce` function.
```
reduce(lambda s,(a,b):s.replace(a,b),[('H','J'),('e','i'),('l','m'),('o','y')],'Hello')
```
[Answer]
If you're doing a *lot* of replaces, you could do this:
```
s=''.join({'H':'J','e':'i','l':'m','o':'y'}[a] for a in list(s))
```
[Answer]
How about defining a lambda function?
```
r=lambda s,a,b:s.replace(a,b)
s=r(r(r(r(s,'H','J'),'e','i'),'l','m'),'o','y')
```
[Answer]
If your replacements don't need to be chained, you can use `str.translate'. The numbers are the ASCII ordinals. Using it this way requires Python 3:
```
print("Hello".translate({72:74,101:105,108:109,111:121}))
```
[**Try it online**](http://ideone.com/3mXbsY)
]