\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{Bromine} \pdfinfo{ /Title (python-in-brief-in-rus.pdf) /Creator (Cheatography) /Author (Bromine) /Subject (Python in brief (in Rus) 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}{BDBDBD} \definecolor{LightBackground}{HTML}{F6F6F6} \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 in brief (in Rus) Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Bromine} via \textcolor{DarkBackground}{\uline{cheatography.com/33505/cs/10425/}}} \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}Bromine \\ \uline{cheatography.com/bromine} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 5th January, 2017.\\ Updated 6th January, 2017.\\ 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{1.64241 cm} x{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Строки ( " STRING " )}} \tn % Row 0 \SetRowColor{LightBackground} `S.{\bf{find}}(str)` & Поиск до первого появления \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `S.{\bf{split}}(sym)` & Разбиение по разделителю \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `str.{\bf{join}}(list)` & Сборка строки из списка \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} `S.{\bf{upper}}()` & Верхний регистр \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} `S.{\bf{lowe}}r()` & Нижний регистр \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} `{\bf{ord}}(sym)` & Символ в его код ASCII \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} `{\bf{chr}}(num)` & Код ASCII в символ \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Списки ( {[} LIST {]} )}} \tn % Row 0 \SetRowColor{LightBackground} `list.{\bf{append}}(x)` & Добавление x \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `list.{\bf{extend}}(L)` & Добавление списка L \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `list.{\bf{insert}}(i,x)` & {\emph{i}}-ый элемент x \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} `list.{\bf{remove}}(x)` & Удаление x \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} `list.{\bf{pop}}({[}i{]})` & Удаление {\emph{i}}-го элемента \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} `list.{\bf{count}}(x)` & Количество элементов x \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} `list.{\bf{sort}}({[}{\bf{key}}=fun{]})` & Сортировка по функции fun \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} `list.{\bf{reverse}}()` & Разворот \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} `list.{\bf{clear}}()` & Очистка \tn % Row Count 18 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.9862 cm} x{1.9908 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Множества ( \{ SET и FROZENSET \} )}} \tn % Row 0 \SetRowColor{LightBackground} `A = {\bf{set}}()` & \seqsplit{Создание} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `A.{\bf{update}}(B)` & A+B \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `A.{\bf{intersection\_update}}(B)` & A∩B \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} `A.{\bf{difference\_update}}(B)` & A\textbackslash{}B \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} `A.{\bf{add}}(x)` & \seqsplit{Добавление} \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} `A.{\bf{remove}}(x)` & \seqsplit{Удаление} \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} `A.{\bf{clear}}()` & Очистка \tn % Row Count 10 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.09034 cm} x{2.88666 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Словари ( \{ DICT : ... \} )}} \tn % Row 0 \SetRowColor{LightBackground} `d={\bf{dict}}(key=val)` & Создание \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `d.{\bf{get}}(key)` & Возврат val по key \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `d.{\bf{items}}()` & Возврат key и val \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} `d.{\bf{keys}}()` & Список ключей \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} `d.{\bf{values}}()` & Список значений \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} `d.{\bf{pop}}(key())` & Удаление key \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} `d.{\bf{update}}({[}d2{]})` & Объединение \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} `d.{\bf{clear}}()` & Очистка \tn % Row Count 15 (+ 1) \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}{Классы и объекты}} \tn % Row 0 \SetRowColor{LightBackground} `{\bf{\_\_class\_\_}}` & Класс объекта \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `{\bf{\_\_dict}}` & Словарь имен \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} `{\bf{\_\_name\_\_}}` & Имя класса \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} `{\bf{\_\_new\_\_}}` & Создание \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} `{\bf{\_\_init\_\_}}` & Иницииация \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} `{\bf{\_\_del\_\_}}` & Удаление \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} `{\bf{\_\_getattr\_\_}}` & Вернуть атрибут \tn % Row Count 11 (+ 2) % Row 7 \SetRowColor{white} `{\bf{\_\_setattr\_\_}}` & Присвоить атрибут \tn % Row Count 13 (+ 2) % Row 8 \SetRowColor{LightBackground} `{\bf{\_\_delattr\_\_}}` & Удалить атрибут \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.23965 cm} x{2.73735 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Встроенные функции}} \tn % Row 0 \SetRowColor{LightBackground} `{\bf{help}}(x)` & Справка \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `{\bf{input}}(text)` , `{\bf{print}}()` & Ввод (+{\emph{text}}) и Вывод \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- & -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} `{\bf{min}}(x)` , `{\bf{max}}(x)` & Минимум и Максимум \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} `{\bf{range}}(a,z,d)` & \seqsplit{Последовательность} \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} `{\bf{sum}}(list)` & Сумма членов \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} `{\bf{abs}}(x)` & Модуль |x| \tn % Row Count 12 (+ 1) % Row 7 \SetRowColor{white} `{\bf{round}}(x,n)` & Округление до {\emph{n}} знаков \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- & -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- \tn % Row Count 16 (+ 2) % Row 9 \SetRowColor{white} `{\bf{type}}(x)` & Тип объекта \tn % Row Count 17 (+ 1) % Row 10 \SetRowColor{LightBackground} `{\bf{len}}(x)` & Число объектов \tn % Row Count 19 (+ 2) % Row 11 \SetRowColor{white} `{\bf{globals}}()` & Глобальные имена \tn % Row Count 21 (+ 2) % Row 12 \SetRowColor{LightBackground} `{\bf{locals}}()` & Локальные имена \tn % Row Count 23 (+ 2) % Row 13 \SetRowColor{white} `{\bf{dir}}(x)` & Список атрибутов \tn % Row Count 25 (+ 2) % Row 14 \SetRowColor{LightBackground} `{\bf{vars}}({[}x{]})` & Словарь атрибутов \tn % Row Count 27 (+ 2) % Row 15 \SetRowColor{white} `{\bf{setattr}}(x,atr,def)` & Установка атрибута \tn % Row Count 29 (+ 2) % Row 16 \SetRowColor{LightBackground} `{\bf{getattr}}(x,atr)` & Извлечение атрибута \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.23965 cm} x{2.73735 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Встроенные функции (cont)}} \tn % Row 17 \SetRowColor{LightBackground} `{\bf{delattr}}(x,atr)` & Удаление атрибута \tn % Row Count 2 (+ 2) % Row 18 \SetRowColor{white} -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- & -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- \tn % Row Count 4 (+ 2) % Row 19 \SetRowColor{LightBackground} `{\bf{eval}}(str\_code)` & Выполнение кода \tn % Row Count 6 (+ 2) % Row 20 \SetRowColor{white} `{\bf{exec}}(code)` & Выполнение кода \tn % Row Count 8 (+ 2) % Row 21 \SetRowColor{LightBackground} -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- & -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- \tn % Row Count 10 (+ 2) % Row 22 \SetRowColor{white} `{\bf{map}}(fun,lst)` & Применение fun к lst \tn % Row Count 12 (+ 2) % Row 23 \SetRowColor{LightBackground} `{\bf{reduce}}(fun,lst)` & Применение fun к lst \tn % Row Count 14 (+ 2) % Row 24 \SetRowColor{white} `{\bf{filter}}(fun,lst)` & Фильтр lst по fun \tn % Row Count 16 (+ 2) % Row 25 \SetRowColor{LightBackground} -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- & -{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}-{}- \tn % Row Count 18 (+ 2) % Row 26 \SetRowColor{white} `{\bf{open}}(file)` & Открыть файл \tn % Row Count 20 (+ 2) % Row 27 \SetRowColor{LightBackground} `file.{\bf{close}}()` & Закрыть файл \tn % Row Count 22 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Генераторы и lambda}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`A=(fun(i) {\bf{for}} i {\bf{in}} list)` {\emph{A\textasciitilde{}( ),\{ \},{[} {]}}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`{\bf{for}} i {\bf{in}} list: {\bf{yield}} fun(i)`} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`({\bf{lambda}} args: fun(args))(values)`} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`A(args) = {\bf{lambda}} args: fun(args)`} \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}