Skip to content

Instantly share code, notes, and snippets.

@ssledz
Last active May 18, 2020 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssledz/59b2a8673b7c5314add9df30a1f1b516 to your computer and use it in GitHub Desktop.
Save ssledz/59b2a8673b7c5314add9df30a1f1b516 to your computer and use it in GitHub Desktop.

install pip & venv

sudo apt-get install python3 python3-pip python3-venv

upgrade pip, setuptools & wheel

python3 -m pip install --upgrade pip setuptools wheel 

creating & activating venv

python3 -m venv .env
source .env/bin/activate

install pipenv & install requests package

pip install --user pipenv
cd project
pipenv install requests

group by -> [('a', 2), ('c', 1), ('b', 3)]

arr = ['a', 'b', 'a', 'c', 'b', 'b']
[(l, sum([1 for e in arr if e == l])) for l in set(arr)]

extension from file -> f_ex = '.pdf'

import os
f_name, f_ext = os.path.splitext('a/b/c.pdf')

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment