1. Installing Packages

1.1. Virtualenv

  • What is Virtualenv
  • Directories
venv/
.venv/

virtualenv/
.virtualenv/

.virtualenv-3.6/
.virtualenv-3.7/

venv-3.6/
venv-3.7/

.venv-3.6/
.venv-3.7/

~/.virtualenv/.../

1.2. Searching

1.3. Installing

  • Alt+Enter on not existing import -> Install Package
  • pip install ...
  • requirements.txt
  • pip install -r requirements.txt

1.4. Using

import ...

1.5. Importing

import sys

sys.path
sys.path.append
sys.path.insert(0, '/path/to/directory')
game
    __init__.py
    config.py
    api.py
    dragon
        __init__.py
        wawelski.py
        red.py
        black.py
        white.py
from game.config import RESOLUTION_MAX_X
from game.dragon import red
from game.dragon import white


my_dragon1 = red.RedDragon()
my_dragon2 = white.WhiteDragon()
from game.dragon import *

my_dragon1 = red.RedDragon()
my_dragon2 = white.WhiteDragon()
from game.dragon.red import RedDragon
from game.dragon.white import WhiteDragon

my_dragon1 = RedDragon()
my_dragon2 = WhiteDragon()
from game.dragon.red import RedDragon as Smok

wawelski = Smok()

1.6. Assignments

1.6.1. Virtualenv

  1. Stwórz virtualenv z instalacją Python
  2. Dodaj virtualenv do Python Interpreter w Twoim IDE

1.6.2. Installing from requirements.txt

  1. Stwórz plik requirements.txt
  2. Dopisz linijkę pycodestyle do requirements.txt
  3. Niech Twoje IDE zainstaluje bibliotekę automatycznie (kliknięcie w żółty banner)
About:
  • Filename: requirements.txt
  • Lines of code to write: 1 line
  • Estimated time of completion: 5 min