Source

pythonwise / partial-demo.py

1
2
3
4
5
6
7
#!/usr/bin/env python

from functools import partial
import re
remove_prefix = partial(re.compile("prefix: ").sub, "")
print remove_prefix("prefix: hello") # 'hello'
print remove_prefix("hello") # 'hello'