\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{Mr Kitty} \pdfinfo{ /Title (intermediate-python.pdf) /Creator (Cheatography) /Author (Mr Kitty) /Subject (Intermediate 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}{000000} \definecolor{LightBackground}{HTML}{F7F7F7} \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{Intermediate Python Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Mr Kitty} via \textcolor{DarkBackground}{\uline{cheatography.com/23005/cs/4937/}}} \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}Mr Kitty \\ \uline{cheatography.com/mr-kitty} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 19th August, 2015.\\ Updated 13th May, 2016.\\ 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}{x{2.23965 cm} x{2.73735 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Built-in Functions}} \tn % Row 0 \SetRowColor{LightBackground} float() & int() \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} bin(num) & hex(num) \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} dict() & list() \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} tuple() & str() \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} complex(a, b) & bool(x) \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} set() & sorted(s) \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} bytes(s) & bytearray(s) \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} abs(num) & len(s) \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} max(s) & min(s) \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} ord(char) & chr(num) \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} pow(x,y) & range({[}start{]} : stop : {[}step{]}) \tn % Row Count 12 (+ 2) % Row 11 \SetRowColor{white} round(num, places) & sum(s) \tn % Row Count 13 (+ 1) % Row 12 \SetRowColor{LightBackground} open(filename, {[}mode{]}) & type(obj) \tn % Row Count 15 (+ 2) % Row 13 \SetRowColor{white} id(obj) & divmod(num, divisor) \tn % Row Count 16 (+ 1) % Row 14 \SetRowColor{LightBackground} input(prompt) & print(s) \tn % Row Count 17 (+ 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}{JSON Module}} \tn % Row 0 \SetRowColor{LightBackground} dump(obj, fp, skipkeys=False, ensure\_ascii=True, \seqsplit{check\_circular=True}, allow\_nan=True, cls=None, indent=None, separators=None, default=None, sort\_keys=False, **kw) & Serialize obj as a JSON formatted stream to fp (a .write()-supporting file-like object) \tn % Row Count 9 (+ 9) % Row 1 \SetRowColor{white} dumps({[}same arguments as above, minus "fp"{]}) & Serialize obj to a JSON formatted str \tn % Row Count 12 (+ 3) % Row 2 \SetRowColor{LightBackground} load({[}same as dump{]}) & Deserialize fp (a .read()-supporting file-like object containing a JSON document) to a Python object \tn % Row Count 17 (+ 5) % Row 3 \SetRowColor{white} loads(s, {[}same arguments as dumps{]}) & Deserialize s (a str instance containing a JSON document) to a Python object \tn % Row Count 21 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{JSON functions have a lot of arguments, you'll only need to use "obj", "fp", and "s" about 99\% of the time though} \tn \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}{Subprocess Module}} \tn % Row 0 \SetRowColor{LightBackground} subprocess.run(args, *, stdin=None, input=None, stdout=None, stderr=None, shell=False, timeout=None, check=False) & The recommended approach to invoking subprocesses. This does not capture stdout or stderr by default. To do so, pass subprocess.PIPE to the appropriate arguments \tn % Row Count 9 (+ 9) % Row 1 \SetRowColor{white} \seqsplit{subprocess.call(args}, *, stdin=None, stdout=None, stderr=None, shell=False, timeout=None) & Run the command described by args. Wait for command to complete, then return the returncode attribute \tn % Row Count 15 (+ 6) % Row 2 \SetRowColor{LightBackground} \seqsplit{subprocess.check\_output(**)} & Run command with arguments and return its output. Same as run(..., check=True, stdout=PIPE).stdout \tn % Row Count 20 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Note that "**" means to use the same arguments as above} \tn \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}{Time Module}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{time.clock()} & On Unix, return the current processor time as a floating point number expressed in seconds \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \seqsplit{time.sleep(secs)} & Suspend execution of the calling thread for the given number of seconds \tn % Row Count 7 (+ 3) \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}{Datetime Module}} \tn % Row 0 \SetRowColor{LightBackground} datetime.date() & An idealized date \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} datetime.time() & An idealized time \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{datetime.datetime(year}, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None) & A combination of time and date \tn % Row Count 7 (+ 5) % Row 3 \SetRowColor{white} \seqsplit{datetime.timedelta(days=0}, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0) & A time difference \tn % Row Count 12 (+ 5) % Row 4 \SetRowColor{LightBackground} datetime.today() & Return the current day \tn % Row Count 14 (+ 2) % Row 5 \SetRowColor{white} \seqsplit{datetime.now(tz=None)} & Return the current time and date \tn % Row Count 16 (+ 2) % Row 6 \SetRowColor{LightBackground} datetime.date() & Return the date portion of a datetime object \tn % Row Count 19 (+ 3) % Row 7 \SetRowColor{white} datetime.time() & Return the time portion of a datetime object \tn % Row Count 22 (+ 3) % Row 8 \SetRowColor{LightBackground} datetime.weekday() & Return the day of the week. Monday = 0 \tn % Row Count 24 (+ 2) % Row 9 \SetRowColor{white} .strftime(format string) & Format a datetime string.\{\{nl\}\}"\%A, \%d. \%B \%Y \%I:\%M\%p" gives "Tuesday, 21. November 2006 04:30PM" \tn % Row Count 29 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Random Module}} \tn % Row 0 \SetRowColor{LightBackground} random.seed(a=None, version=2) & Initialize the random number generator \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} random.randrange({[}start,{]} stop{[}, step{]}) & Return a randomly selected element from range(start, stop, step) \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} random.randint(a, b) & Return a random integer N such that a \textless{}= N \textless{}= b \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} random.choice(seq) & Return a random element from the non-empty sequence seq \tn % Row Count 12 (+ 3) % Row 4 \SetRowColor{LightBackground} random.shuffle(x) & Shuffle the sequence x in place \tn % Row Count 14 (+ 2) % Row 5 \SetRowColor{white} \seqsplit{random.sample(population}, k) & Return a k length list of unique elements chosen from the population sequence or set \tn % Row Count 19 (+ 5) % Row 6 \SetRowColor{LightBackground} random.random() & Return the next random floating point number in the range {[}0.0, 1.0) \tn % Row Count 23 (+ 4) % Row 7 \SetRowColor{white} \seqsplit{random.normalvariate(mu}, sigma) & Normal distribution. mu is the mean, and sigma is the standard deviation \tn % Row Count 27 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Warning: the pseudo-random generators of this module should not be used for security purposes.} \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}{Os Module}} \tn % Row 0 \SetRowColor{LightBackground} os.uname & Return the operating system, release, version and machine as a tuple \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \seqsplit{os.chdir(path)} & Change working directory \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} os.getcwd() & Returns the current working directory \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{os.listdir(path='.')} & Return a list containing the names of the entries in the directory given by path \tn % Row Count 11 (+ 4) % Row 4 \SetRowColor{LightBackground} \seqsplit{os.system(command)} & Execute the command (a string) in a subshell. Replaced by the subprocess module \tn % Row Count 15 (+ 4) \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}{Regular Expressions Module}} \tn % Row 0 \SetRowColor{LightBackground} compile(pattern, flags=0) & Compile a regular expression pattern into a regular expression object ("regex") \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} regex.search(string{[}, pos{[}, endpos{]}{]}) & Scan through string looking for a location where this regular expression produces a match, and return a corresponding match object \tn % Row Count 11 (+ 7) % Row 2 \SetRowColor{LightBackground} regex.match(string{[}, pos{[}, endpos{]}{]}) & If zero or more characters at the beginning of string match this regular expression, return a corresponding match object \tn % Row Count 17 (+ 6) % Row 3 \SetRowColor{white} regex.fullmatch(string{[}, pos{[}, endpos{]}{]}) & If the whole string matches this regular expression, return a corresponding match object \tn % Row Count 22 (+ 5) % Row 4 \SetRowColor{LightBackground} match.group({[}group1, ...{]}) & Returns one or more subgroups of the match. Group "0" is the entire match \tn % Row Count 26 (+ 4) % Row 5 \SetRowColor{white} \seqsplit{match.groups(default=None)} & Return a tuple containing all the subgroups of the match \tn % Row Count 29 (+ 3) \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}{Smtplib Module}} \tn % Row 0 \SetRowColor{LightBackground} SMTP(host='', port=0, \seqsplit{local\_hostname=None}, {[}timeout, {]}source\_address=None) & A SMTP instance encapsulates an SMTP connection. For normal use, you should only require the \seqsplit{initialization/connect}, sendmail(), and quit() methods \tn % Row Count 8 (+ 8) % Row 1 \SetRowColor{white} \seqsplit{MTP.connect(host='localhost'}, port=0) & Connect to a host on a given port. The defaults are to connect to the local host at the standard SMTP port (25) \tn % Row Count 14 (+ 6) % Row 2 \SetRowColor{LightBackground} SMTP.helo(name='') & Identify yourself to the SMTP server using HELO \tn % Row Count 17 (+ 3) % Row 3 \SetRowColor{white} SMTP.login(user, password) & Log in on an SMTP server that requires authentication \tn % Row Count 20 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{SMTP.starttls(keyfile=None}, certfile=None, context=None) & Put the SMTP connection in TLS (Transport Layer Security) mode. All SMTP commands that follow will be encrypted \tn % Row Count 26 (+ 6) % Row 5 \SetRowColor{white} \seqsplit{SMTP.sendmail(from\_addr}, to\_addrs, msg, mail\_options={[}{]}, rcpt\_options={[}{]}) & Send mail \tn % Row Count 30 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Smtplib Module (cont)}} \tn % Row 6 \SetRowColor{LightBackground} SMTP.quit() & Terminate the SMTP session and close the connection \tn % Row Count 3 (+ 3) \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}{Threading Module}} \tn % Row 0 \SetRowColor{LightBackground} Thread(group=None, target=None, name=None, args=(), kwargs=\{\}, *, daemon=None) & The main class of the this module. You use this to initialise a new thread \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} Thread.start() & Start the thread's activity \tn % Row Count 6 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{Thread.join(timeout=None)} & Wait until the thread terminates \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} Thread.is\_alive() & Return whether the thread is alive \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} Lock() & The class implementing primitive lock objects. Once a thread has acquired a lock, subsequent attempts to acquire it block, until it is released; any thread may release it \tn % Row Count 19 (+ 9) % Row 5 \SetRowColor{white} \seqsplit{Lock.acquire(blocking=True}, timeout=-1) & Acquire a lock, blocking or non-blocking \tn % Row Count 21 (+ 2) % Row 6 \SetRowColor{LightBackground} Lock.release() & Release a lock. This can be called from any thread, not only the thread which has acquired the lock \tn % Row Count 26 (+ 5) % Row 7 \SetRowColor{white} Semaphore(value=1) & This class implements semaphore objects. A semaphore manages a counter representing the number of release() calls minus the number of acquire() calls, plus an initial value. The acquire() method blocks if necessary until it can return without making the counter negative \tn % Row Count 40 (+ 14) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Threading Module (cont)}} \tn % Row 8 \SetRowColor{LightBackground} \seqsplit{Semaphore.acquire(blocking=True}, timeout=None) & cquire a semaphore \tn % Row Count 3 (+ 3) % Row 9 \SetRowColor{white} Semaphore.release() & Release a semaphore, incrementing the internal counter by one \tn % Row Count 7 (+ 4) % Row 10 \SetRowColor{LightBackground} \seqsplit{BoundedSemaphore(value=1)} & Class implementing bounded semaphore objects. A bounded semaphore checks to make sure its current value doesn't exceed its initial value \tn % Row Count 14 (+ 7) % Row 11 \SetRowColor{white} Timer(interval, function, args=None, kwargs=None) & Create a timer that will run function with arguments args and keyword arguments kwargs, after interval seconds have passed \tn % Row Count 21 (+ 7) % Row 12 \SetRowColor{LightBackground} Timer.cancel() & Stop the timer, and cancel the execution of the timer's action \tn % Row Count 25 (+ 4) \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}{Argparse Module}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{ArgumentParser(prog=None}, usage=None, description=None, prefix\_chars='-', \seqsplit{argument\_default=None}, add\_help=True) & Create a new ArgumentParser object. All parameters should be passed as keyword arguments \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} \seqsplit{ArgumentParser.add\_argument(name} or flags...{[}, action{]}{[}, nargs{]}{[}, const{]}{[}, default{]}{[}, type{]}{[}, choices{]}{[}, required{]}{[}, help{]}{[}, metavar{]}{[}, dest{]}) & Define how a single command-line argument should be parsed \tn % Row Count 14 (+ 8) % Row 2 \SetRowColor{LightBackground} \seqsplit{ArgumentParser.parse\_args(args=None}, namespace=None) & Convert argument strings to objects and assign them as attributes of the namespace. Return the populated namespace \tn % Row Count 20 (+ 6) % Row 3 \SetRowColor{white} \seqsplit{ArgumentParser.print\_usage(file=None)} & Print a brief description of how the ArgumentParser should be invoked on the command line \tn % Row Count 25 (+ 5) % Row 4 \SetRowColor{LightBackground} \seqsplit{ArgumentParser.print\_help(file=None)} & Print a help message, including the program usage and information about the arguments registered with the ArgumentParser \tn % Row Count 31 (+ 6) \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}{Traceback Module}} \tn % Row 0 \SetRowColor{LightBackground} print\_tb(traceback, limit=None, file=None) & Print up to limit stack trace entries from traceback. If limit is omitted or None, all entries are printed \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} \seqsplit{print\_exception(type}, value, traceback, limit=None, file=None, chain=True) & Print exception information and up to limit stack trace entries from traceback to file. Note that it prints the exception type and value after the stack trace \tn % Row Count 14 (+ 8) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{You can get the traceback and other debugging info with: \newline exc\_type, exc\_value, exc\_traceback = sys.exc\_info() \newline (exc is short for "Exception")} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}