Table of contents
Coding Standards
PEP 8 — Style Guide for Python Code - This document gives coding conventions for the Python code comprising the standard library in the main Python distribution. Please see the companion informational PEP describing style guidelines for the C code in the C implementation of Python
Virtual Python Environment
A Virtual Environment is a tool to keep the dependencies required by different projects in separate places, by creating virtual Python environments for them. It solves the “Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keeps your global site-packages directory clean and manageable.1
A Virtual Environment is a tool to keep the dependencies required by different projects in separate places, by creating virtual Python environments for them. It solves the “Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keeps your global site-packages directory clean and manageable.2
Table of contents
References
- Virtual Environments - The Hitchhiker's Guide to Python
- A Primer on virtualenv
Installation
$ sudo pip install virtualenv
Create an Environment
$ which python3 or $ which python3.6
where {env-name} is the name for your project, etc. and the -p path is too the version of Python you want to use in this environment, for example Python 3.x
$ virtualenv ./venv -p /usr/bin/python3.6
Activate the VirtualEnv
$ source ./venv/bin/activate
VirtualEnv Dependencies
pip freeze
- pip freeze - pip 18.1 documentation
When you are using a virtualenv, you can specify a requirements.txt file to install all the dependencies.3
(venv)$ pip freeze > requirements.txt
(venv)$ pip install -r requirements.txt
PyCharm - virtualenv
PyCharm - virtualenv makes it possible create virtual environment using the virtualenv tool. So doing, PyCharm tightly integrates with virtualenv, and enables configuring virtual environments right in the IDE.4
gitignore
Gitignore - Specifies intentionally untracked files to ignore5
gitignore Command Line Generator
gi pycharm,python >> .gitignore
Git
Git is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows. Git was initially designed and developed by Linus Torvalds for Linux kernel development in 2005, and has since become the most widely adopted version control system for software development.6
Python Gitignore
Gitignore - Specifies intentionally untracked files to ignore7
wget -O .gitignore https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
shebang
#!/usr/bin/env python3
IDLE
IDLE is Python’s Integrated Development and Learning Environment.8
sudo apt-get install idle3
sudo yum install python-tools
Sublime
Sublime Text is a sophisticated text editor for code, markup and prose. You'll love the slick user interface, extraordinary features and amazing performance.9
- An Overview of Sublime Text 2 with Python - One of the key tools of each developer is a good integrated developer environment (IDE). Python is a beautiful language with great support from a budding community of developers, who continue to create amazing libraries and extensions.
- Setting up Sublime Text for Python development - I recently started using Sublime Text 2 more and more as my main editor for Python development. This article explains my setup and some tweaks that make Python programmers happy.
gitignore
wget -O .gitignore https://raw.githubusercontent.com/github/gitignore/master/Global/SublimeText.gitignore
Related Topices