diff options
author | neodarz <neodarz@neodarz.net> | 2019-09-05 07:05:07 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2019-09-05 07:05:07 +0200 |
commit | e0c0d4b38cde20e2300e86b69414dd9851b47456 (patch) | |
tree | 5df65243447352a9637d1f783247bfd5ccff2ef4 /dotfiles/cheat/python | |
parent | dc45bf89a66ec6c8cd25cf5605deb853f6984705 (diff) | |
download | dotfiles_dotdrop-e0c0d4b38cde20e2300e86b69414dd9851b47456.tar.xz dotfiles_dotdrop-e0c0d4b38cde20e2300e86b69414dd9851b47456.zip |
ooo
Diffstat (limited to '')
-rw-r--r-- | dotfiles/cheat/python | 63 | ||||
-rw-r--r-- | dotfiles/cheat/python_ressources | 20 |
2 files changed, 83 insertions, 0 deletions
diff --git a/dotfiles/cheat/python b/dotfiles/cheat/python new file mode 100644 index 0000000..7c8f0b2 --- /dev/null +++ b/dotfiles/cheat/python @@ -0,0 +1,63 @@ +# Desc: Python is a high-level programming language. + +# Basic example of server with python +# Will start a Web Server in the current directory on port 8000 +# go to http://127.0.0.1:8000 + +# Python v2.7 +python -m SimpleHTTPServer +# Python 3 +python -m http.server 8000 + +# SMTP-Server for debugging, messages will be discarded, and printed on stdout. +python -m smtpd -n -c DebuggingServer localhost:1025 + +# Pretty print a json +python -mjson.tool + +# Generate requirements.txt +pipreqs /path/to/project + +# Tips +# Ressources available in : cheat python_ressources + +Input: décoder avec `decode()`. +Output: encoder avec `encode('utf-8')` + +lors de l'ouverture d'un fichier: +``` +from codecs import open + +# open() de codec à exactement la même API, y compris avec "with" +f = open('fichier', encoding='encoding') +``` + +# Types + +bytes == bytearray + +# non mutable (non modifiable) +bytes +tuple + +# mutable (modifiable) +bytearray + +# For bytes and bytearray show hex value of each char +[hex(i) for i in header] + +# For string show hex value of each char +[hex(ord(c)) for c in header] + +# Opencv with gstreamer +# Gstreamer not on pipy but present when building... + +git clone --recursive https://github.com/skvark/opencv-python.git +git checkout -b 25 +ENABLE_CONTRIB=ON python setup.py install + +# package developement + +virtualenv .venv_dev +source .venv_dev/bin/activate +pip install -e . # for install package in dev mode diff --git a/dotfiles/cheat/python_ressources b/dotfiles/cheat/python_ressources new file mode 100644 index 0000000..cf8a350 --- /dev/null +++ b/dotfiles/cheat/python_ressources @@ -0,0 +1,20 @@ +# Python + +## Encoding python +http://sametmax.com/lencoding-en-python-une-bonne-fois-pour-toute/ + +## Prog par contre +http://sametmax.com/programmation-par-contrat-avec-assert/ + +## Critique ORM +http://sametmax.com/les-critiques-des-orm-sont-a-cote-de-la-plaque/ + +# For python > 3.8 + +## Expression designation +http://sametmax.com/lexpression-dassignation-vient-detre-acceptee/ + +# Version resumy + +## Python 3.7 +http://sametmax.com/python-3-7-sort-de-sa-coquille/ |