Python Home
Introduction
Running Python Programs (os, sys, import)
Modules and IDLE (Import, Reload, exec)
Object Types - Numbers, Strings, and None
Strings - Escape Sequence, Raw String, and Slicing
Strings - Methods
Formatting Strings - expressions and method calls
Files and os.path
Traversing directories recursively
Subprocess Module
Regular Expressions with Python
Regular Expressions Cheat Sheet
Object Types - Lists
Object Types - Dictionaries and Tuples
Functions def, *args, **kargs
Functions lambda
Built-in Functions
map, filter, and reduce
Decorators
List Comprehension
Sets (union/intersection) and itertools - Jaccard coefficient and shingling to check plagiarism
Hashing (Hash tables and hashlib)
Dictionary Comprehension with zip
The yield keyword
Generator Functions and Expressions
generator.send() method
Iterators
Classes and Instances (__init__, __call__, etc.)
if__name__ '__main__'
argparse
Exceptions
@static method vs class method
Private attributes and private methods
bits, bytes, bitstring, and constBitStream
json.dump(s) and json.load(s)
Python Object Serialization - pickle and json
Python Object Serialization - yaml and json
Priority queue and heap queue data structure
Graph data structure
Dijkstra's shortest path algorithm
Prim's spanning tree algorithm
Closure
Functional programming in Python
Remote running a local file using ssh
SQLite 3 - A. Connecting to DB, create/drop table, and insert data into a table
SQLite 3 - B. Selecting, updating and deleting data
MongoDB with PyMongo I - Installing MongoDB ...
Python HTTP Web Services - urllib, httplib2
Web scraping with Selenium for checking domain availability
REST API : Http Requests for Humans with Flask
Blog app with Tornado
Multithreading ...
Python Network Programming I - Basic Server / Client : A Basics
Python Network Programming I - Basic Server / Client : B File Transfer
Python Network Programming II - Chat Server / Client
Python Network Programming III - Echo Server using socketserver network framework
Python Network Programming IV - Asynchronous Request Handling : ThreadingMixIn and ForkingMixIn
Python Coding Questions I
Python Coding Questions II
Python Coding Questions III
Python Coding Questions IV
Python Coding Questions V
Python Coding Questions VI
Python Coding Questions VII
Python Coding Questions VIII
Image processing with Python image library Pillow
Python and C++ with SIP
PyDev with Eclipse
Matplotlib
Redis with Python
NumPy array basics A
NumPy Matrix and Linear Algebra
Pandas with NumPy and Matplotlib
Celluar Automata
Batch gradient descent algorithm
Longest Common Substring Algorithm
Python Unit Test - TDD using unittest.TestCase class
Simple tool - Google page ranking by keywords
Google App Hello World
Google App webapp2 and WSGI
Uploading Google App Hello World
Python 2 vs Python 3
virtualenv and virtualenvwrapper
Uploading a big file to AWS S3 using boto module
Scheduled stopping and starting an AWS instance
Cloudera CDH5 - Scheduled stopping and starting services
Removing Cloud Files - Rackspace API with curl and subprocess
Checking if a process is running/hanging and stop/run a scheduled task on Windows
Apache Spark 1.3 with PySpark (Spark Python API) Shell
Apache Spark 1.2 Streaming
bottle 0.12.7 - Fast and simple WSGI-micro framework for small web-applications ...
Flask app with Apache WSGI on Ubuntu14/CentOS7 ...
Selenium WebDriver
Fabric - streamlining the use of SSH for application deployment
Ansible Quick Preview - Setting up web servers with Nginx, configure enviroments, and deploy an App
Neural Networks with backpropagation for XOR using one hidden layer
NLP - NLTK (Natural Language Toolkit) ...
RabbitMQ(Message broker server) and Celery(Task queue) ...
OpenCV3 and Matplotlib ...
Simple tool - Concatenating slides using FFmpeg ...
iPython - Signal Processing with NumPy
iPython and Jupyter - Install Jupyter, iPython Notebook, drawing with Matplotlib, and publishing it to Github
iPython and Jupyter Notebook with Embedded D3.js
Downloading YouTube videos using youtube-dl embedded with Python
Machine Learning : scikit-learn ...
Django 1.6/1.8 Web Framework ...
Regex Syntax¶
Regex Cheat Sheet. GitHub Gist: instantly share code, notes, and snippets. Description (?:) Don’t capture group. 250-5 Match 251-255 pattern. 20-40-9 Match 200-249 pattern 1?0-90-9 Match 0-199 pattern. Regular Expressions Cheat Sheet for Python, PHP, Perl, JavaScript and Ruby developers. The list of the most important metacharacters you'll ever need.
Character | Matches |
---|---|
a | a character |
. | Any character (except newline) |
. | . character |
| character |
* | * character |
Matches | Description | |
---|---|---|
[abcd] | Any one of the letters a through d | Set of characters |
[^abcd] | Any character but a , b , c , or d | Complement of a set of characters |
[a-d] | Any one of the letters a through d | Range of characters |
[a-dz] | Any of a , b , c , d , or z | Range of characters |
Type | Expression | Equivalent To | Description |
---|---|---|---|
Word Character | w | [a-zA-Z0-9_] | Alphanumeric or underscore |
Non-word Character | W | [^a-zA-Z0-9_] | Anything but a word character |
Digit Character | d | [0-9] | Numeric |
Non-digit Character | D | [^0-9] | Non-numeric |
Whitespace Character | s | [tnrfv] | Whitespace |
Non-whitespace Character | S | [^tnrfv] | Anything but a whitespace character |
Anchor | Matches |
---|---|
^ | Start of the string |
$ | End of the string |
b | Boundary between word and non-word characters |
Group Type | Expression |
---|---|
Capturing | ( ... ) |
Non-capturing | (?: ... ) |
Quantifier | Modification |
---|---|
{5} | Match expression exactly 5 times |
{2,5} | Match expression 2 to 5 times |
{2,} | Match expression 2 or more times |
{,5} | Match expression 0 to 5 times |
* | Match expression 0 or more times |
{,} | Match expression 0 or more times |
? | Match expression 0 or 1 times |
{0,1} | Match expression 0 or 1 times |
+ | Match expression 1 or more times |
{1,} | Match expression 1 or more times |
Quantifier | Modification |
---|---|
{2,5}? | Match 2 to 5 times (less preferred) |
{2,}? | Match 2 or more times (less preferred) |
{,5}? | Match 0 to 5 times (less preferred) |
*? | Match 0 or more times (less preferred) |
{,}? | Match 0 or more times (less preferred) |
?? | Match 0 or 1 times (less preferred) |
{0,1}? | Match 0 or 1 times (less preferred) |
+? | Match 1 or more times (less preferred) |
{1,}? | Match 1 or more times (less preferred) |
Quantifier | Modification |
---|---|
ABC|DEF | Match string ABC or string DEF |
Quantifier | Modification |
---|---|
(?=abc) | Zero-width match confirming abc will match upcoming chars |
(?!abc) | Zero-width match confirming abc will not match upcoming chars |
Python¶
Function | Purpose | Usage |
---|---|---|
re.search | Return a match object if pattern found in string | re.search(r'[pat]tern','string') |
re.finditer | Return an iterable of match objects (one for each match) | re.finditer(r'[pat]tern','string') |
re.findall | Return a list of all matched strings (different when capture groups) | re.findall(r'[pat]tern','string') |
re.split | Split string by regex delimeter & return string list | re.split(r'[-]','st-ring') |
re.compile | Compile a regular expression pattern for later use | re.compile(r'[pat]tern') |
Flag | Description |
---|---|
re.IGNORECASE | Match uppercase and lowercase characters interchangeably |
re.VERBOSE | Ignore whitespace characters and allow # comments |
How To Use Regex In Python
↑
I send out 1 Python exercise every week through a Python skill-building service called Python Morsels.
Python Regex Cheatsheet Pdf
If you'd like to improve your Python skills every week, sign up!