Table of Contents

Data Types

Types

				
					CHAR
String (0 - 255)
VARCHAR
String (0 - 255)
TINYTEXT
String (0 - 255)
TEXT
String (0 - 65535)
BLOB
String (0 - 65535)
MEDIUMTEXT
String (0 - 16777215)
MEDIUMBLOB
String (0 - 16777215)
LONGTEXT
String (0 - 429496-7295)
LONGBLOB
String (0 - 429496-7295)
TINYINT x
Integer (-128 to 127)
SMALLINT x
Integer (-32768 to 32767)
MEDIUMINT x
Integer (-8388608 to 8388607)
INT x
Integer (-2147-483648 to 214748-3647)
BIGINT x
Integer (-9223-372-036-854-775808 to 922337-203-685-477-5807)
FLOAT
Decimal (precise to 23 digits)
DOUBLE
Decimal (24 to 53 digits)
DECIMAL
"-DOU-BLE-" stored as string
DATE
YYYY-MM-DD
DATETIME
YYYY-MM-DD HH:MM:SS
TIMESTAMP
YYYYMM-DDH-HMMSS
TIME
HH:MM:SS
ENUM
One of preset options
SET
Selection of preset options
				
			

Array

Array Methods

Indexes and Slices

				
					a=[0,1,2,3,4,5]
len(a) >>> 6
a[0] >>>> 0
a[5] >>>> 5
a[-1] >>> 5
a[-2] >>>> 4
a[1:] >>>> [1,2,3,4,5]
a[:5] >>>> [0,1,2,3,4]
a[:-2] >>> [0,1,2,3]
a[1:3] >>> [1,2]
a[1:-1] >>>> [1,2,3,4]
b=a[:] >>>>> Shallow copy of a
				
			

Operating System

OS Variables

				
					altsep:
    Alternative sep
curdir:
    Current dir string
defpath:
    Default search path
devnull:
    Path of null device
extsep:
    Extension separator
linesep:
    Line separator
name:
    Name of OS
pardir:
    Parent dir string
pathsep:
    Patch separator
sep:
    Path separator
				
			

String Formatting

Formatting Operations

				
					'd'
    Signed integer decimal.
'i'
    Signed integer decimal.
'o'
    Signed octal value.
'u'
    Obsolete type – it is identical to 'd'.
'x'
    Signed hexadecimal (lowercase).
'X'
    Signed hexadecimal (uppercase).
'e'
    Floating point exponential format (lowercase).
'E'
    Floating point exponential format (uppercase).
'f'
    Floating point decimal format.
'F'
    Floating point decimal format.
'g'
    Floating point format. Uses lowercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise.
'G'
    Floating point format. Uses uppercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise.
'c'
    Single character (accepts integer or single character string).
'r'
    String (converts any Python object using repr().
's'
    String (converts any Python object using str()
'%'
    No argument is converted, results in a     '%' character in the result.
				
			

Class

Special Methods

  • __new__(cls)
  • __lt__(self, other)
  • __init__(self, args)
  • __le__(self, other)
  • __del__(self)
  • __gt__(self, other)
  • __repr__(self)
  • __ge__(self, other)
  • __str__(self)
  • __eq__(self, other)
  • __cmp__(self, other)
  • __ne__(self, other)
  • __index__(self)
  • __nonzero__(self)
  • __hash__(self)
  • __getattr__(self, name)
  • __getattribute__(self, name)
  • __setattr__(self, name, attr)
  • __delattr__(self, name)
  • __call__(self, args, kwargs)

Date Formate

Date Formatting

				
					%a
    Abbreviated weekday (Sun)
%A
    Weekday (Sunday)
%b
    Abbreviated month name (Jan)
%B
    Month name (January)
%c
    Date and time
%d
    Day (leading zeros) (01 to 31)
%H
    24 hour (leading zeros) (00 to 23)
%I
    12 hour (leading zeros) (01 to 12)
%j
    Day of year (001 to 366)
%m
    Month (01 to 12)
%M
    Minute (00 to 59)
%p
    AM or PM
%S
    Second (00 to 61?)
%U
    Week number1 (00 to 53)
%w
    Weekday2 (0 to 6)
%W
    Week number3 (00 to 53)
%x
    Date
%X
    Time
%y
    Year without century (00 to 99)
%Y
    Year (2008)
%Z
    Time zone (GMT)
%%
    A literal "%" character (%)
				
			

Sys

Sys Variables

				
					argv
    Command line args
builtin_module_names
    Linked C modules
byteorder
    Native byte order
check_-interval
    Signal check frequency
exec_prefix
    Root directory
executable
    Name of executable
exitfunc
    Exit function name
modules
    Loaded modules
path
    Search path
platform
    Current platform
stdin, stdout, stderr
    File objects for I/O
version_info
    Python version info
winver
    Version number
				
			

sys.argv

				
					sys.argv[0] >>> foo.py
bar >>> sys.argv[1]
-c >>> sys.argv[2]
qux >>> sys.argv[3]
--h >>> sys.argv[4]
				
			

Math

Number Theoretic

Power and Logarithmic

Angular Conversion

Hyperbolic Functions

Constants

				
					math.pi
    The mathematical constant π = 3.141592..., to available precision.
math.e
    The mathematical constant e = 2.718281..., to available precision.