Magic commands in IPython
IPython is a integrated Python interface, and it introduces a set of magic commands which start with %
. These magic commands are very handy when we use IPython. This post discusses several helpful magic commands.
Backreference in Python's re.sub Function
While regular expression is a widely-used technique in text processing, it seems a not-easy-to-learn technique. Often, an experienced programmer might find an unfamiliar point. I have been using regular expression in bash for several years, but when I switched to Python, I found it a totally new world. I finished reading the regular expression chapters in Beginning Python by Magnus Lie and Core Python Programming 2nd ed by Wesley Chun, but neither of them has mentioned the backreference mechanism in Python. In this post, we will discuss about backreference in Python, and will use the case in sed as illustration.