CS6
Practical
System
Skills
Fall 2019 edition
Leonhard Spiegelberg
lspiegel@[Link]
Open questions from last lecture
2
15.20 Checking out remote tags
⇒ clone the repo first via git clone, then you can list available
tags via git tag -l
⇒ checkout a specific tag via git checkout tags/<tagname>
Example:
git clone [Link] &&
cd go-ethereum &&
git checkout tags/v1.0.2
3 / 46
15.21 git checkout --ours / --theirs in rebase
⇒ To rebase on the master run
git checkout feature && git rebase master
⇒ you can use git checkout --ours or git checkout --theirs
→ Note: Meaning of theirs/ours is flipped in rebase mode, i.e.
--theirs is referring to the feature branch
--ours is referring to the master branch
→ to continue the rebase if no changes are made to the
commit, use git rebase --skip
4 / 59
16 Python
CS6 Practical System Skills
Fall 2019
Leonhard Spiegelberg lspiegel@[Link]
16.01 What is python?
⇒ developed by Guido van Rossum in the early 1990s
→ named after Monty Python, has a snake as mascot
⇒ python is an interpreted language
⇒ dynamically typed, i.e. the type of a variable
is determined during runtime
⇒ high-level language with many built-in
features like lists, tuples, dictionaries (hashmaps),
sets, ...
6 / 59
16.02 Who uses python?
Web backend Data analysis
+ many more + many more
Note: An interesting talk why Instagram choose Python [Link] 7 / 59
16.02 Python resources
Official tutorial: [Link]
Other useful resources:
[Link]
[Link]
+ many more available online on Udemy, Coursera, ...
8 / 59
16.03 Installing python
⇒ There are many python versions, we'll be using python 3.7
→ often you see code for python 2.7,
however 2.7 will be deprecated 2020
⇒ Use a package manager to install python:
- Mac OS X
brew install python3
- Ubuntu:
sudo apt update && sudo apt install software-properties-common &&
sudo add-apt-repository ppa:deadsnakes/ppa &&
sudo apt install python3.7
- Debian: [Link]
9 / 59
16.04 Working with python - how to develop code?
⇒ the python interpreter can be accessed using different ways.
Popular are
(1) interactive mode
entering python3 in bash starts python3 in REPL mode,
python3 -c "<some python3 code>"can be used to directly execute code
(2) file mode
save code in a file and execute via python3 [Link] or ./[Link] with a
shebang line. There are also IDEs like pycharm to work with .py files
(3) notebooks
instead of the limited REPL, have a web interface to work like in Mathematica.
Popular are jupyter notebooks or zeppelin notebooks. Many vendors also have
commercial notebook offerings (IBM/Databricks/Cloudera/Google/MS/…). 10 / 59
16.05 python in interactive mode
tuxmachine:~ tux$ python3
Python 3.7.4 (default, Sep 28 2019, 16:39:19)
[Clang 11.0.0 (clang-1100.0.33.8)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> credits
Thanks to CWI, CNRI, [Link], Zope Corporation and a cast of thousands
for supporting Python development. See [Link] for more information.
>>> 1 + 2
3
>>> x = 17 you can type expressions or
statements
>>> x ** 2
289
>>> exit() use exit() to quit the
REPL or Ctrl + D
11 / 59
16.06 python in file mode
echo -e '#!/usr/bin/env python3\nprint("hello world!")' > [Link] &&
python3 [Link]
execute file in python3
hello world
chmod +x [Link] && ./[Link] specifying a shebang line
allows execution via ./
python3 -c 'print("hello world!")'
-c option to specify python
program as string (works for
bash too)
12 / 59
16.06 Python IDEs
⇒ There are multiple IDEs
available for python3
development
- PyCharm (free for students
w. Github education pack)
- Spyder
- Visual Studio with Python
Tools for Visual Studio
13 / 59
16.07 Notebooks
⇒ Popular (especially amongst data
scientists) are notebooks
→ we'll be using jupyter notebooks
⇒ Install them via
pip3 install jupyter
(python package index)
⇒ start via jupyter notebook
(launches notebook webui)
*intall pip via instructions on [Link] or on Ubuntu via apt-get install python3-pip 14 / 59
python3 language essentials
15
16.08 Time to learn some python!
⇒ best via interactive notebook!
⇒ git clone [Link]
⇒ Lab today: Intro to Python
16 / 59
End of lecture.
Next class: Thu, 4pm-5:20pm @ CIT 477