Python Cheat Sheet

A Programming › Python cheat sheet in English by shribee

Python quick reference

2,506 views 730 downloads 1 Aug 2022 History

List

A = [1,2,3]
B = A[:]
create new list as copy

Enviro­nments

conda create --name <env name> python­=<v­ers­ion>
create enviro­nment
conda activate <env name>
activate enviro­nment
conda deactivate
deactivate enviro­nment
conda install <pkg name>
install package
conda update conda
update conda
conda info
verify conda is installed, check version number
conda env list
list of enviro­nments
conda list
list all packages and versions installed in active enviro­nment
conda list --explicit > <text file>
save enviro­nment to a text file
conda env create --file <text file>
create enviro­nment from a text file
where python
location of python installs
python --version
python version

Change jupyter notebook start directory

jupyter notebook --gene­rat­e-c­onfig
This writes a file to C:\Use­rs­\use­rna­me\.ju­pyt­er­\jup­yte­r_n­ote­boo­k_c­onf­ig.py
Change this line
#c.Not­ebo­okA­pp.n­ot­ebo­ok_dir = '­'
to this text
c.Note­boo­kAp­p.n­ote­boo­k_dir = '­/th­e/p­ath­/to­/ho­me/­fol­der­/'

Comments

No comments yet.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.