|
Python Tips
Tab-completion in Python Interpreter
By adding the following lines to your .pythonrc file (or whatever file you have
set Python to read on startup):
import rlcompleter, readline
readline.parse_and_bind('tab: complete')
...you can make Python complete partially typed function, method, and variable names
by pressing the TAB key. Note that this tip requires that the "readline" module
be available on your system (it is on Unix/Linux, but doesn't seem to be on
Windows).
A friendlier way to build regular expressions
Regular expressions look like the result of a poorly educated monkey playing
with the keyboard but which actually perform complex search and replace
operations on strings of text. I couldn't help but feel that there must be
a better way to do this, and sure enough Ka-Ping Yee has created a module
called "rxb" which does just that. If you are new to regular expressions,
or just sick of their stupid syntax, take a look
here (there are some other nice scripts
there too).
|