From 255337ed1aa47128275ff0a80fa7c9147e2900a7 Mon Sep 17 00:00:00 2001 From: Kenneth Odle Date: Sun, 30 Jul 2023 17:45:02 -0400 Subject: [PATCH] Updated 2 vs 3 section --- Notes on Python.tex | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Notes on Python.tex b/Notes on Python.tex index b050042..f85a465 100644 --- a/Notes on Python.tex +++ b/Notes on Python.tex @@ -85,9 +85,6 @@ \begin{tikzpicture} \draw [white, line width=6] (0,0) -- (0.1,0); \end{tikzpicture} } -% Make a Python Symbol like a LaTeX symbol -\newcommand\kpy{P{\scriptsize \raisebox{-0.4em}{\hspace{-0.16em}Y}}T{\scriptsize \raisebox{-0.3em}{h}}\hspace{-0.15em}\raisebox{0.4em}{o}\hspace{0.05em}\raisebox{-0.2em}N} - % Additional options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \raggedbottom @@ -148,14 +145,29 @@ Python is platform independent. It emphasizes a concise syntax that aids in code \bigskip -Many fields depend on \kpy\footnote{This is my attempt to produce a text symbol for Python, similar to \LaTeX{}. My thought is that it looks like a snake wriggling back and forth. Your mileage, of course, may (and probably will) vary. If you would like to use this in your own documents (why?) I have defined it as a macro, which you can obtain from the source code for this document. See the abstract for its location.} to process data. +Many fields depend on Python to process data. -Mueller\cite{mueller-jp:23} has many reasons why a knowledge of Python may be useful in a job search. \kpull{This is \textit{not} my favorite book.}{22mm} They were fairly accurate as of their publication (2023),but things change quickly, so a keyword search of your preferred job boards is always in order. +Mueller\cite{mueller-jp:23} has many reasons why a knowledge of Python may be useful in a job search. They were fairly accurate as of their publication (2023),but things change quickly, so a keyword search of your preferred job boards is always in order. \subsection{IDEs and Python} \subsection{Version 2 versus Version 3} +The initial version of Python 2 was released in 2000. Python 2.7, which was released in 2010, is the last version of Python 2. Many people continue to use Python 2, but they shouldn't, and neither should you. + +Python 3 was released in December 2008 and is a drastically different language than Python 2. Among other things, + +\begin{enumerate}[noitemsep] + \item Python 3 stores strings as Unicode, whereas Python 2 stores them as ASCII. + \item Python 3 considers ``print'' to be a function, whereas Python 2 considers it to be a statement. + \item Python 3's syntax is simpler. + \item Python 3 has improved performance. + \item The result of integer division in Python 3 is a float value (i.e., $5\div2=2.5$) whereas in Python 2 it was an integer value which truncated decimals (i.e., $5\div2=2$). + \item Most of the new libraries for Python 3 cannot be used in Python 2. +\end{enumerate} + +Most importantly, the Python project stopped supporting Python 2 after 31 December 2019, meaning \kpull{\textit{Use Python 3!}}{1in} that it is not getting bug fixes or security updates. Anything written in Python 2 is not as efficient, and definitely not as secure, as anything written in Python 3. + \subsection{Comments in Python} Python supports single line comments by adding a hashtag (\texttt{\#}) to the beginning of each line: