Python

Python GUI Frontend Options Comparison

2021-01-14. Category & Tags: Python, GUI, Desktop, Windows, Linux, Cross-Platfrom

Mainly for the (cross-platform) Python GUI frontend options. CEF (Chromium Embedded Framework). Pro: can use the same way of MVC thinking (modern html5); build-in chromium browser. Con: someone said it may need a little c++. PyQt (v5). Pro: big community, good doc (for c++). Con: c++ way of thinking, just the language is py (the official GUI tutorial lacks GUI screenshots!); pay for commercial usage; still often needs c++. Tkinter. Pro: build-in w/ py, big community. ...

Python-docx for MS Word

2021-01-12. Category & Tags: Python, MS Word, Pyhon-Docx, Docx

As the pyhon-docx does not want to provide a documentation (except some APIs) and the API doc web is really hard to browse and read, here are some small tips/demo tutorials to remember/avoid pits and falls. Please note: lib (0.8) provides only basic functions mainly for adding something (seems to be for test purpose). The main actions we do in a docx file should be done using MS API via this lib. ...

Python Convert Images to PDF

2020-03-18. Category & Tags: Python, Image, Picture, Pdf, Parallel

Two methods of downloading & converting pictures/images to a combined pdf file with parallel (multi-thread) from Mark Needham. f.write(img2pdf.convert(…)) [ref MarkHNeedham] from PIL import Image [ref DataToFish] Note: fpdf is not suggested as it canNOT support jpg natively. [ref stackoverflow]

Plot in Python, Visualization wtih pyvis

2019-07-05. Category & Tags: Jupyter, Python, Visualisation, Matplotlib, PyViz, Plot

Books & Docs # Seaborn tutorial & gallary OReilly 2017 - [easy to find common examples] Python Data Science Handbook Packt 2015 - [nice code grammar] Python Data Visualization Cookbook, 2nd Ed. (Igor Milovanovic) Packt 2015 - [rich & various content] Mastering Python Data Visualization Packt 2015 - [advanced nice plots & deployments] Mastering matplotlib (D.M. McGreggor) [Very bad composition] Packt 2018 - Matplotlib for Python Developers - 2nd Ed (by Allen Yu, Claire Chung) Overview of Libs # Python Data Visualisation Landscape ...

Python Code Cookbook

2018-07-01. Category & Tags: Default Python, Reuse, Import, Include

See also: LearnPython, the Language Pandas # Get column_nr in pandas/numpy. if isinstance(X, pd.DataFrame): X_is_df = True row_nr = X.shape[0] column_nr = X.shape[1] if isinstance(X.columns, pd.core.index.MultiIndex): df_columns_is_multi_index = True else: df_columns_is_multi_index = False else: # non-DF X_is_df = False row_nr = np.shape(X)[0] column_nr = np.shape(X)[1] use dataframe directly against spark # lib Optimus from optimus import Optimus op = Optimus(master="local") df = op.create.df(<some data>) ... Sourcing/Importing # execfile or os.system # execute the other python file in place: ...

Python Code Reuse

2018-07-01. Category & Tags: Default Python, Reuse, Import, Include

execfile or os.system # execute the other python file in place: execfile("/path/to/my/lib/mylib.py") or: import os os.system("python /path/to/my/lib/mylib.py") import # import sys import os sys.path.append(os.path.abspath("/path/to/my/lib")) import mylib ref # See other methods here.

Learning Falcon

2018-01-13. Category & Tags: Python, Falcon, API

A great 5-video tutorial: 35minutes on YouTube (6 tomatoes / 2.5 hours for non-stop studing by coding). Author’s Github (py2), My Github (py3). Differences in my Github code: py3, not py2 using on_put() to test validity of input json from client using on_delete() to test params (just to test, should NOT be used in real-world) using another route /test2?x=1&y=3 to test params Usage in Nix: pip3 install falcon gunicorn gunicorn app:api # in the folder of app. ...

Python the Language (in case of)

2016-08-21. Category & Tags: Python, Environment, Virtual Environment, UV, Py, Py3, Lang, Language

Related: /jupyter /Learn-Django /python-gui: desktop GUI/frontend /py-cookbook : code reuse /pyvis: plot in py Python in Win by MS official tutorial CN 用 Rust 让 numpy、scikit 和 pandas 加速 100 倍!开源 Weld 技术揭秘 学 Python ,开头几件事: 熟悉基础语法 + 使用虚拟环境。 之后,考虑:1. 基于 uv 使用 AI-IDE; 2. Linux。 Basic Py Grammar 基础语法 # 基础教程: 菜鸟教程 runoob.com (提示:此网页中的“高级教程”是指基础教程的高级部分), 如果不是专业软件开发人员,只是做科研实验,可以先学基础的基础,即学到“编程第一步”,“编程第一步”之后的内容用 1 小时过一遍备查即可。 重要:对于基础的基础示例代码,一定要跟着一个字母一个字母敲(做到自己完全能写出来一段,熟悉这些基础函数的调用方法和常用参数),绝对不要直接复制粘贴。 以下是虚拟环境管理器(UV)和基于虚拟环境管理器安装其他版本的 Py # PRE-INSTALL: UV, CONDA VS. PIP # Pip requires apt. ...

Learning Django

2016-08-18. Category & Tags: Python, Django, Web

(updated 2021.1) Related: Learn Python Ref: This is a combined learning note of: basic level sentdex’s youtube tutorial 2016, the corresponding video+text one is here. official tutorial which is still too complicated for new users, so better to use that after following this blog. middle level another tutorial: Django Tutorials for Beginners 2016 book “O’Reilly 2014 - Test-Driven Development with Python (django 1.7)”. official docs: DOCs.DjangoProject.com. all-in-one 3.8-hour video. Python Django Web Framework - Full Course for Beginners 2018 w/ Code (in sublime). ...

Jupyter

2016-08-06. Category & Tags: Jupyter, Python

INSTALL # Anaconda Way # This is suggested for very new users to use a stable environment. It is NOT suitable for normal users / experienced programmers / engineers. for windows # Download Python 3 from Anaconda and install. From Windows “Start” menu, run “Jupyter” directly. (jupyter since anacodna v5.3.1) For old anacodna versions, run from navigator as below: anaconda for linux # In CLI, see here. Or, in GUI, similar to windows. ...