Coding - Programs and Tweaks
Sublime Text
A nice text editor with good theming and visual appeal
A good basic setup:
- Theme: Preferences » Theme » Adaptive
- Colors: Preferences » Color Scheme » Monokai
Extensions
- Package Control - A nice way to add and remove packages to sublime. You need this for all other visual tweaks
- Material Theme - Beautiful theming using material design. Be sure to set the colors back to Monokai afterward
- Theme settings:
"material_theme_accent_cyan": true, "material_theme_big_fileicons": true, "material_theme_bright_scrollbars": true, "material_theme_compact_sidebar": true, "material_theme_contrast_mode": true, "material_theme_small_tab": true, "material_theme_titlebar": true, "theme": "Material-Theme-Darker.sublime-theme"
- Theme settings:
- Sync Settings - A nice tool to sync sublime settings using github gists.
Windows right-click menu items
This registy file adds several right-click options:
- Open any file with Sublime
- Open any folder with Sublime
- by right-clicking on the folder
- by right clicking on any white space inside the folder
Enjoy!
Spyder
Python IDE
Settings
- Tools » Preferences » Syntax Coloring » Monokai
- Tools » Preferences » iPython Console » Graphics » Backend » Automatic
QDarkStyle
Doesn’t Work
QDarkStyle dark mode for spyder. Here are the instructions from someone on StackOverflow
I tried it by placing the correct line here: C:\ProgramData\Anaconda2\Lib\site-packages\spyder\app
, but it sort of looks like garbage. For now I’m sticking to the white window with dark Monokai syntax highlighting.
Dark Fusion
Doesn’t Work
Based on the instructions from this Github Issue
- Put
darkflat.py
intoC:\ProgramData\Anaconda2\Lib\site-packages\spyder\
- This is a modified version of the original code.
- Modifications: Refactored the class definition to not rely on
super
- Additions:
from qtpy.QtGui import QPalette, QColor from qtpy import QtCore
- Subtractions:
#! /usr/bin/env python3
- Add the following three lines right before the
return
statement in theinitialize
function inapp/mainwindow.py
from spyder import darkflat palette = darkflat.QDarkPalette() palette.set_app(app)
- Follow Repligon’s instructions to make all uncolored icons white.
Note: I tried this as well, but this styling didn’t affect the title bar or the tabs in spyder’s editor. I ultimately abandoned my attempts to add a nice dark mode to Spyder 3.
Jupyter Notebooks
Install Monokai theme using jupyter-themes:
pip install jupyterthemes # install jupyterthemes
jt -t monokai -T # Use monokai theme and enable the toobar (-T)
As seen on this post on StackOverflow
Python Best Practices
Packages
When making python packages, I follow Scott Torborg’s guide for how to package python code
Tweaks I make to his style guide:
- I place the
tests
folder in the main folder (not in the package directory) - I don’t use the
unittest.TestCase
class
Upload open source packages to PyPI
Follow this guide to build and upload your package
- Build your package
- increment the version number
- Delete the
build
anddist
folders) python setup.py sdist bdist_wheel
- Check that the package will work correctly
twine check dist/*
- Test your package on the test server. You will need to make an account there too (it’s completely separate)
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
- Upload for real
twine upload dist/*
- It seems that sometimes PyPi’s servers don’t update the available version number right away, but according to this GitHub issue, you can force that to happen
curl -X PURGE https://pypi.python.org/simple/[YOUR PACKAGE NAME]
Virtual Environments
- Install venv:
sudo apt install python3-venv
- Create a folder to store virtual environments (mine is in ~Documents/virtual_envs)
- Create a new virtual environment:
python3 -m venv ~/Documents/virtual_envs/[ENV NAME]
- Activate a virtual environment in a terminal:
source ~/Documents/virtual_envs/[ENV NAME]/bin/activate