\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{filoucool} \pdfinfo{ /Title (python.pdf) /Creator (Cheatography) /Author (filoucool) /Subject (Python Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{9C9C9C} \definecolor{LightBackground}{HTML}{F8F8F8} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Python Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{filoucool} via \textcolor{DarkBackground}{\uline{cheatography.com/157372/cs/33337/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}filoucool \\ \uline{cheatography.com/filoucool} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 25th July, 2022.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{p{0.79363 cm} x{0.91894 cm} p{0.79363 cm} x{1.6708 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{5.377cm}}{\bf\textcolor{white}{Comparison Operators}} \tn % Row 0 \SetRowColor{LightBackground} x\textless{} y & Less & x \textless{}= y & Less or eq \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} x \textgreater{} y & Greater & x \textgreater{}= y & Greater or eq \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} x == y & Equal & x != y & Not equal \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{1.28156 cm} x{1.78503 cm} p{1.51041 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Boolean Operators}} \tn % Row 0 \SetRowColor{LightBackground} not x & x and y & x or y \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.79363 cm} x{1.21133 cm} p{0.91894 cm} x{1.2531 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{5.377cm}}{\bf\textcolor{white}{Arithmetic Operators}} \tn % Row 0 \SetRowColor{LightBackground} x + y & add & x - y & subtract \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} x * y & multiply & x / y & divide \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} x \% y & modulus & x ** y & x\textasciicircum{}y\textasciicircum{} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}----} \SetRowColor{LightBackground} \mymulticolumn{4}{x{5.377cm}}{Assignment shortcuts: x op= y \newline Example: x += 1 increments x} \tn \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Exception Handling}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{try: \newline statements \newline except {[} exception type {[} asvar {]} {]}: \newline statements \newline finally: \newline statements} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.84149 cm} x{3.13551 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{String / List / Tuple Operations}} \tn % Row 0 \SetRowColor{LightBackground} len({\emph{s}}) & length of s \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\emph{s{[}i{]}}} & ith item in s (0-based) \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\emph{s{[}start : end{]}}} & slice of {\emph{s}} from {\emph{start}} (included) to {\emph{end}} (excluded) \tn % Row Count 5 (+ 3) % Row 3 \SetRowColor{white} {\emph{x}} in {\emph{s}} & {\bf{True}} if {\emph{x}} is contained in {\emph{s}} \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} {\emph{x}} not in s{\emph{ }} & {\bf{True}} if {\emph{x}} is not contained in {\emph{s}} \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} {\emph{s}} + {\emph{t}} & the concatenation of {\emph{s}} with {\emph{t}} \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} {\emph{s}} {\emph{*}} {\emph{n}} & {\emph{n}} copies of {\emph{s}} concatenated \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} sorted({\emph{s}}) & a sorted copy of {\emph{s}} \tn % Row Count 14 (+ 1) % Row 8 \SetRowColor{LightBackground} {\emph{s}}.index({\emph{item}}) & position in {\emph{s}} of {\emph{item}} \tn % Row Count 16 (+ 2) % Row 9 \SetRowColor{white} {\emph{s}}.lower() & lowercase copy of {\emph{s}} \tn % Row Count 17 (+ 1) % Row 10 \SetRowColor{LightBackground} {\emph{s}}.replace({\emph{old, new}}) & copy of {\emph{s}} with old replaced with {\emph{new}} \tn % Row Count 19 (+ 2) % Row 11 \SetRowColor{white} {\emph{s}}.split({\emph{delim}}) & list of substrings delimited by {\emph{delim}} \tn % Row Count 21 (+ 2) % Row 12 \SetRowColor{LightBackground} {\emph{s}}.strip() & copy of {\emph{s}} with whitespace trimmed \tn % Row Count 23 (+ 2) % Row 13 \SetRowColor{white} {\emph{s}}.upper() & uppercase copy of {\emph{s}} \tn % Row Count 24 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{See also \newline http://docs.python.org/library/stdtypes.html\#stringmethods} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.9954 cm} x{3.9816 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Environment}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{sys.argv} & List of command line arguments (argv{[}0{]} is executable) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{os.environ} & Dictionary of environment variables \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{os.curdir} & String with path of current directory \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{import sys; print(sys.argv) or \newline from sys import argv; print(argv)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.38896 cm} x{2.58804 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Python List Methods}} \tn % Row 0 \SetRowColor{LightBackground} append({\emph{item}}) & pop({\emph{position}}) \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} count({\emph{item}}) & remove({\emph{item}}) \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} extend({\emph{list}}) & reverse() \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} index({\emph{item}}) & sort() \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{insert({\emph{position, item}})} \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.23505 cm} p{1.74195 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Python sys.argv}} \tn % Row 0 \SetRowColor{LightBackground} sys.argv{[}0{]} & foo.py \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} sys.argv{[}1{]} & bar \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} sys.argv{[}2{]} & -c \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} sys.argv{[}3{]} & qux \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} sys.argv{[}4{]} & -{}-h \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{sys.argv for the command: \newline \$ python foo.py bar -c qux -{}-h} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Function Definitions}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{def {\emph{name}}({\emph{arg1, arg2, ...}}): \newline {\emph{statements}} \newline return expr} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.64241 cm} x{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Conversion Functions}} \tn % Row 0 \SetRowColor{LightBackground} int({\emph{expr}}) & Converts {\emph{expr}} to integer \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} float({\emph{expr}}) & Converts {\emph{expr}} to float \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} str({\emph{expr}}) & Converts {\emph{expr}} to string \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} chr({\emph{num}}) & ASCII char {\emph{num}} \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.09494 cm} x{3.88206 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Data Types}} \tn % Row 0 \SetRowColor{LightBackground} Integer & -256, 15 \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Float & -253.23, 1.253e-10 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} String & "Hello", 'Goodbye', """Multiline""" \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} Boolean & True, False \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} List & {[} value, ... {]} \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} Tuple & ( value, ... ) \textasciicircum{}1\textasciicircum{} \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} \seqsplit{Dictionary} & \{ key: value, ... \} \tn % Row Count 9 (+ 2) % Row 7 \SetRowColor{white} Set & \{ value, value, ... \} \textasciicircum{}2\textasciicircum{} \tn % Row Count 10 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{1. Parentheses usually optional \newline 2. Create an empty set with set()} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.69218 cm} x{3.28482 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Mutating List Operations}} \tn % Row 0 \SetRowColor{LightBackground} del {\emph{lst{[}i{]}}} & Deletes {\emph{i}}th item from lst \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\emph{lst}}.append({\emph{e}}) & Appends {\emph{e}} to {\emph{lst}} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\emph{lst}}.insert({\emph{i, e}}) & Inserts {\emph{e}} before {\emph{i}}th item in {\emph{l}}st \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} {\emph{lst}}.sort() & Sorts {\emph{lst}} \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{See also \newline https://docs.python.org/3/library/stdtypes.html\#typesseq-mutable} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.9908 cm} x{2.9862 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Python File Methods}} \tn % Row 0 \SetRowColor{LightBackground} close() & readlines({\emph{size}}) \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} flush() & seek({\emph{offset}}) \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} fileno() & tell() \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} isatty() & truncate({\emph{size}}) \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} next() & write({\emph{string}}) \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} read({\emph{size}}) & writelines({\emph{list}}) \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{readline({\emph{size}})} \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Python Indexes and Slices}} \tn % Row 0 \SetRowColor{LightBackground} len(a) & 6 \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} a{[}0{]} & h \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} a{[}5{]} & n \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} a{[}-1{]} & n \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} a{[}-2{]} & m \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} a{[}1:{]} & {[}i,j,k,m,n{]} \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} a{[}:5{]} & {[}h,i,j,k,m{]} \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} a{[}:-2{]} & {[}h,i,j,k{]} \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} a{[}1:3{]} & {[}i,j{]} \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} a{[}1:-1{]} & {[}i,j,k,m{]} \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} b=a{[}:{]} & Shallow copy of a \tn % Row Count 11 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Indexes and Slices of a={[}h,i,j,k,m,n{]}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Statements}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{If Statement}} \newline if {\emph{expression}}: \newline {\emph{statements}} \newline elif {\emph{expression}}: \newline {\emph{statements}} \newline else: \newline {\emph{statements}} \newline {\bf{While Loop}} \newline while {\emph{expression}}: \newline {\emph{statements}} \newline {\bf{For Loop}} \newline for {\emph{var}} in {\emph{collection}}: \newline {\emph{statements}} \newline {\bf{Counting For Loop}} \newline for i in range({\emph{start, end {[}, step{]}}}): \newline {\emph{statements}} \newline ({\emph{start}} is included; {\emph{end}} is not)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Python Date Formatting}} \tn % Row 0 \SetRowColor{LightBackground} \%a & Abbreviated weekday (Sun) \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \%A & Weekday (Sunday) \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \%b & Abbreviated month name (Jan) \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \%B & Month name (January) \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \%c & Date and time \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \%d & Day (leading zeros) (01 to 31) \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \%H & 24 hour (leading zeros) (00 to 23) \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} \%I & 12 hour (leading zeros) (01 to 12) \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} \%j & Day of year (001 to 366) \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} \%m & Month (01 to 12) \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} \%M & Minute (00 to 59) \tn % Row Count 11 (+ 1) % Row 11 \SetRowColor{white} \%p & AM or PM \tn % Row Count 12 (+ 1) % Row 12 \SetRowColor{LightBackground} \%S & Second (00 to 61$^{\textrm{4}}$) \tn % Row Count 13 (+ 1) % Row 13 \SetRowColor{white} \%U & Week number$^{\textrm{1}}$ (00 to 53) \tn % Row Count 14 (+ 1) % Row 14 \SetRowColor{LightBackground} \%w & Weekday$^{\textrm{2}}$ (0 to 6) \tn % Row Count 15 (+ 1) % Row 15 \SetRowColor{white} \%W & Week number$^{\textrm{3}}$ (00 to 53) \tn % Row Count 16 (+ 1) % Row 16 \SetRowColor{LightBackground} \%x & Date \tn % Row Count 17 (+ 1) % Row 17 \SetRowColor{white} \%X & Time \tn % Row Count 18 (+ 1) % Row 18 \SetRowColor{LightBackground} \%y & Year without century (00 to 99) \tn % Row Count 19 (+ 1) % Row 19 \SetRowColor{white} \%Y & Year (2008) \tn % Row Count 20 (+ 1) % Row 20 \SetRowColor{LightBackground} \%Z & Time zone (GMT) \tn % Row Count 21 (+ 1) % Row 21 \SetRowColor{white} \%\% & A literal "\%" character (\%) \tn % Row Count 22 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{$^{\textrm{1}}$ Sunday as start of week. All days in a new \newline year preceding the first Sunday are \newline considered to be in week 0. \newline $^{\textrm{2}}$ 0 is Sunday, 6 is Saturday. \newline $^{\textrm{3}}$ Monday as start of week. All days in a new \newline year preceding the first Monday are \newline considered to be in week 0. \newline $^{\textrm{4}}$ This is not a mistake. Range takes \newline account of leap and double-leap seconds.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Python Datetime Methods}} \tn % Row 0 \SetRowColor{LightBackground} today() & fromordinal({\emph{ordinal}}) \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} now({\emph{timezoneinfo}}) & combine({\emph{date, time}}) \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} utcnow() & strptime({\emph{date, format}}) \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{fromtimestamp({\emph{timestamp}})} \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{utcfromtimestamp({\emph{timestamp}})} \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.53827 cm} x{2.43873 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Python Class Special Methods}} \tn % Row 0 \SetRowColor{LightBackground} \_\_new\_\_(cls) & \_\_lt\_\_(self, other) \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \_\_init\_\_(self, args) & \_\_le\_\_(self, other) \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \_\_del\_\_(self) & \_\_gt\_\_(self, other) \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \_\_repr\_\_(self) & \_\_ge\_\_(self, other) \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \_\_str\_\_(self) & \_\_eq\_\_(self, other) \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \_\_cmp\_\_(self, other) & \_\_ne\_\_(self, other) \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \_\_index\_\_(self) & \_\_nonzero\_\_(self) \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{\_\_hash\_\_(self)} \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{\_\_getattribute\_\_(self}, name)} \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{\_\_setattr\_\_(self, name, attr)} \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\_\_delattr\_\_(self, name)} \tn % Row Count 11 (+ 1) % Row 11 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{\_\_getattr\_\_(self, name)} \tn % Row Count 12 (+ 1) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\_\_call\_\_(self, args, kwargs)} \tn % Row Count 13 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Python Time Methods}} \tn % Row 0 \SetRowColor{LightBackground} replace() & utcoffset() \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} isoformat() & dst() \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \_\_str\_\_() & tzname() \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{strftime({\emph{format}})} \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}