Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
python-cheat-sheet-v1
1. sys Variables String Methods Datetime Methods
today() fromordinal(ordinal)
argv Command line args capitalize() * lstrip()
now(timezoneinfo) combine(date, time)
builtin_module_names Linked C modules center(width) partition(sep)
utcnow() strptime(date, format)
byteorder Native byte order replace(old, new)
count(sub, start, end)
fromtimestamp(timestamp)
check_interval Signal check frequency decode() rfind(sub, start ,end)
utcfromtimestamp(timestamp)
exec_prefix Root directory encode() rindex(sub, start, end)
executable Name of executable endswith(sub) rjust(width)
exitfunc Exit function name expandtabs() rpartition(sep)
Time Methods
modules Loaded modules find(sub, start, end) rsplit(sep)
replace() utcoffset()
path Search path rstrip()
index(sub, start, end)
isoformat() dst()
platform Current platform isalnum() * split(sep)
__str__() tzname()
stdin, stdout, stderr File objects for I/O isalpha() * splitlines()
strftime(format)
version_info Python version info isdigit() * startswith(sub)
winver Version number islower() * strip()
isspace() * swapcase() *
Date Formatting (strftime and strptime)
istitle() * title() *
sys.argv for $ python foo.py bar qux
%a Abbreviated weekday (Sun)
isupper() * translate(table)
sys.argv[0] %A Weekday (Sunday)
foo.py join() upper() *
sys.argv[1] %b Abbreviated month name (Jan)
bar ljust(width) zfill(width)
sys.argv[2] %B Month name (January)
qux lower() *
%c Date and time
%d Day (leading zeros) (01 to 31)
Methods marked * are locale
os Variables Note dependant for 8-bit strings. %H 24 hour (leading zeros) (00 to 23)
Alternative sep
altsep %I 12 hour (leading zeros) (01 to 12)
Current dir string
curdir %j Day of year (001 to 366)
List Methods
Default search path
defpath %m Month (01 to 12)
Path of null device
devnull %M Minute (00 to 59)
append(item) pop(position)
Extension separator
extsep %p AM or PM
count(item) remove(item)
Line separator
linesep %S Second (00 to 61 4)
extend(list) reverse()
Name of OS
name %U Week number (00 to 53)
index(item) sort() 1
Parent dir string
pardir %w Weekday (0 to 6)
insert(position, item) 2
Patch separator
pathsep %W Week number (00 to 53)
3
Path separator
sep %x Date
File Methods
%X Time
%y Year without century (00 to 99)
close() readlines(size)
Registered OS names: “posix”, “nt”,
Note “mac”, “os2”, “ce”, “java”, “riscos” %Y Year (2008)
flush() seek(offset)
%Z Time zone (GMT)
fileno() tell()
%% A literal quot;%quot; character (%)
isatty() truncate(size)
Class Special Methods
next() write(string)
1.
read(size) writelines(list) Sunday as start of week. All days in a
__new__(cls) __lt__(self, other)
readline(size) new year preceding the first Sunday
__init__(self, args) __le__(self, other)
are considered to be in week 0.
__del__(self) __gt__(self, other)
__repr__(self) __ge__(self, other) Indexes and Slices (of a=[0,1,2,3,4,5])
2. 0 is Sunday, 6 is Saturday.
__str__(self) __eq__(self, other)
len(a) 6
__cmp__(self, other) __ne__(self, other)
a[0] 3.
0 Monday as start of week. All days in a
__index__(self) __nonzero__(self)
a[5] 5 new year preceding the first Monday
__hash__(self)
a[-1] 5 are considered to be in week 0.
__getattr__(self, name)
a[-2] 4
__getattribute__(self, name)
a[1:] 4.
[1,2,3,4,5] This is not a mistake. Range takes
__setattr__(self, name, attr)
a[:5] [0,1,2,3,4] account of leap and double-leap
__delattr__(self, name)
a[:-2] [0,1,2,3] seconds.
__call__(self, args, kwargs)
a[1:3] [1,2]
a[1:-1] [1,2,3,4]
Available free from AddedBytes.com
b=a[:] Shallow copy of a