Learn Python - The Hard Way
Overview
Set of simple programs written during learning basics of Python language based on Learn Python - The Hard Way course. All tasks can be found in exercises directory. In the same directory, we can found another README.md
file including list of all tasks. Moreover, this README.md
file includes important and essential information concerning programming in Python. You can also read a short article about this project on my blog.
Contents
- Requirements
- Installing Python
- Executing Python scripts from terminal
- Pip
- Installing Pip on Windows
- Installing Pip on Linux
- Installing Pip on macOS
- Using Pip
- Unit Testing
- Virtualenv
- Pipenv
- Pyenv
- Scripts on Linux
- Style Guide for Python Code
- Static code analysis
- Development Environments
- Python web frameworks
- Useful Python libraries
- Tools written in Python
- Collections of tools written in Python
- Resources
- Videos
- Books
- License
Requirements
- Windows, Linux or Mac OS X
- Python 2.7
- Pip (Python Package Manager)
Installing Python
- on Linux: Most of the Linux distributions should have installed Python by default
- on Windows: Download Python at: https://www.python.org/downloads/windows/ and run installer
- on Mac OS X: Download Python at: https://www.python.org/downloads/mac-osx/
Executing Python scripts from terminal
- on Linux: Most of the Linux distributions should have enabled Python by default, so simply open terminal and type python to see if everything works.
- on Windows: add
/PythonXX
(e.g.C:/Python27
) intoPath
environmental variable. Location of the Python directory depends on your configuration. Next, re-run terminal window and typepython
- in order to check installed version of the Python, type:
python --version
- in order to exit python console type
exit()
Pip
Pip is a Python Package Manager.
Installing Pip on Windows
- Download: https://bootstrap.pypa.io/get-pip.py script
- Execute:
python get-pip.py
- pip.exe and easy_install.exe files now should be located at: /PythonXX/Scripts (e.g. C:/Python27/Scripts)
- Add /PythonXX/Scripts (e.g. C:/Python27/Scripts) directory into Path environmental variable.
- Re-run terminal window
- Type
pip
, to check if package manager works - You can type
pip --version
, in order to check version of the pip
Installing Pip on Linux
- Open terminal
- Type
sudo apt-get install python-pip
Installing Pip on macOS
- Open terminal
- Type
brew install python3
This command will install python and pip.
Using Pip
- In order to install desired package just type
pip install desired_package
(e.g.pip install Flask
) - If you are working on Linux, type
sudo pip install desired_package
(e.g.sudo pip install Flask
) - Index of available packages can be found at: https://pypi.python.org/pypi/
- List of installed packages can be displayed with
pip freeze
command.
Unit Testing
- UT in Python can be done with nose. Install it via pip with the following command:
sudo pip install nose
- UT can be also created with unittest package provided with Python.
Virtualenv
virtualenv
is a tool to create isolated Python environments.
More information:
- Official docs and user guide
- Overview on PyPi
- Virtualenv tutorial
- A primer on virtualenv
- Virtual Environments on Python Guide
Pipenv
pipenv
is Python Development Workflow for Humans.
It automatically creates and manages a virtualenv for your projects, as well as adds/removes packages from your Pipfile as you install/uninstall packages.
More information:
Pyenv
pyenv is a simple Python version management.
Scripts on Linux
If we want to create a Python script for Linux, we should set the following header:
#!/usr/bin/python -u
# your Python script code goes here...
After that when our script was saved in script.py
file, we can execute our script as follows:
./script.py
Style Guide for Python Code
PEP 0008 is a current Style Guide for Python Code.
link: https://www.python.org/dev/peps/pep-0008/
code style: https://docs.python-guide.org/writing/style/
Static Code Analysis
- Pylint
- Pytype (by Google)
- Review of Python static code analysis tools
- Awesome static analysis for Python
Development Environments
Python web frameworks
Web servers
Useful Python libraries
- Requests - HTTP requests for humans
- Httpie - CLI HTTP client
- Python Rex - regular expressions for humans
- PythonVerbalExpressions - readable API for regular expressions
- Envelopes - mailing for human beings
- Tornado - web framework and asynchronous networking library
- Schedule - Python job scheduling for humans
- Agate - data analysis for humans
- Gspread - Google Spreadsheets Python API
- EFILTER (dotty) - a general-purpose destructuring and search language
- Scrapy - web crawling & scraping framework
- sh - Python process launching (allows you to call any program as if it were a function)
- furl - url parsing and manipulation
- schedule - python job scheduling for humans
Tools written in Python
- Wifite - an automated wireless attack tool
- Glances - an Eye on your system
- Pidcat - colored and improved logcat for Android apps
- Caffeine-plus - indicator preventing from turning screensaver/screenlock on
- Spaceship generator - a script for Blender
- neighbourhood - Layer 2 network neighbourhood discovery tool that uses scapy
- Routersploit - The Router Exploitation Framework
- scanless - port scanner
- graph-cli - plot graphs out of csv files
Collections of tools written in Python
- Python Pentest Tools
- awesome-python - curated list of awesome Python frameworks, libraries and software
- one-python - best Python libraries
Resources
- https://www.python.org/
- http://learnpythonthehardway.org/book/
- http://www.codecademy.com/en/tracks/python
- http://www.diveintopython.net/
- https://github.com/kennethreitz/python-guide
- http://www.pyvideo.org/speaker/138/raymond-hettinger
- https://github.com/s16h/py-must-watch
- http://pymust.watch/
- http://slides.com/fwkz/awesome-python
- http://docs.python-guide.org/en/latest/
- https://github.com/bslatkin/effectivepython
- https://github.com/kennethreitz/python-guide
- https://github.com/Junnplus/awesome-python-books
- https://github.com/crazyguitar/pysheeet
- https://github.com/satwikkansal/wtfpython
- https://mail.python.org/pipermail/python-list/1999-June/001951.html
- https://github.com/trekhleb/learn-python
- https://docs.python-guide.org/writing/style/
- https://realpython.com/
- https://python-for-system-administrators.readthedocs.io/en/latest/
- https://konradhalas.pl/articles/python-resources/
- https://github.com/machinelearningmindset/machine-learning-course
Videos
Books
License
MIT