home ‣ Python quick(er) reference (a bigger one)

Quick links: regexps

Invocation: python[w] [-dEhimOQStuUvVWxX?] [-c command | scriptFile | - ] [args]

Keywords:

Env variables:

Strings:

Boolean: True, False (since 2.2.1)

Numbers:

Sequences:

Dictionaries: {}, {1 : "first"}, {"foo" : "bar", 2 : "ah"}

Ops on all numeric types:

Bit operations:

Ops on sequences:

Ops on mutable sequences:

sys module:

os module:

os.path module:

stat module:

re module:
RegExp object:
Match object:

Regular expressions: (more detailed info)
re.match(regexp, string) returns None or Match object if a regular expression matches the beginning of the string. re.search(regexp, string) returns None or Match object if regular expression matches anywhere in the string.
Alternatively you can compile regular expression with: regexpObj = re.compile(regexp[,flags]) and use regexpObj.search(string) and regexpObj.match(string).

Match object group() returns part of the string that matched. start() and end() return start/end position of a match within string. span() returns a tuple (start, end) position of a match.

Regular expressions special sequences: