Verbose regexes in Python
You can use verbose regexes in Python. Whitespace and comments will be stripped off by the compiler, so they're just as efficient, but more readable:
ignore_re = re.compile(r"""
^\..*/ # skip dotfiles
| docs/ # skip our docs
| /migrations/ # migrations
| ^[^/]+$ # a path without directories
""", re.VERBOSE)
Written by Vincent Driessen
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#