Python

A programming language that is designed to be easy to read and use.
web | documentation | wikipedia | feed

See also | :django
See also (alternative) | :ruby

Notes

Development setup

If you are going to be programming your own project, or running someone else's project from source, you will need to create an isolated virtual environment for that project. In this virtualenv you will store the external libraries that project requires, separate from your system libraries and other project libraries. The following intructions will help you install and configure tools for managing Python and virtualenvs, including an IDE.

Now you can start learning and developing...

GNOME integration

PyGObject (aka PyGI)
A Python API for :gnome integration
https://wiki.gnome.org/action/show/Projects/PyGObject

PyGObject for Windows
https://sourceforge.net/projects/pygobjectwin32/
"Cross-platform python dynamic bindings of GObject-based libraries for Windows 32-bit and 64-bit."

Reference

Learning Python

The Hitchiker's Guide to Python

(aka the Python Guide) An excellent and well-maintained reference for Python programmers. Advice for every stage in a project, for different types of projects, as well as useful resources and summaries of well-regarded Python packages.
web | project | issues

Awesome Python

A curated list of well-regarded Python libraries.
project | issues

Using curly braces in Python

Advanced programming languages like C++ and Java use braces. To use braces in Python, try the following:

from __future__ import braces

Testing

https://tox.readthedocs.io/en/latest/

https://docs.python.org/2/library/doctest.html
https://docs.python.org/3/library/doctest.html

Other libraries

Much like the original Hitchhiker's Guide, not all packages have entries in the Python Guide or Awesome Python list. Here are some of them:

datetime strftime reference
http://strftime.org
See also https://pyformat.info

Ensure
Python library for assertions that can be used in production code as well as test frameworks.
code | documentation | pypi

Flake8
Python library to check code quality (PEP8, McCabe complexity)
code | documentation | pypi

huey
Multi-threaded task queue (includes cron jobs)
https://github.com/coleifer/huey

pep8radius
project | etc

Secret Storage interface
https://pythonhosted.org/SecretStorage/

Python Call Graph
http://pycallgraph.slowchop.com/en/master/index.html

See also

Code snippets

Desktop indicator
Example of ... appindicator? or something custom?
http://feedproxy.google.com/~r/LifereaBlog/~3/Jd3Yi8goqy4/GTK-StatusIcon-Example-with-PyGI

String formatting

https://pyformat.info

Using variables in string formatting

message = "Message with {fieldname} in it."
message.format(fieldname = value)

message = "Message with %(name)s in it." % {"name": value, }

TODO: what if variables "fieldname" and "value" have the same name? is there a shortcut?



Backlinks: blender alembic-python qt sqlalchemy pycharm menagerie fish mysql reahl imagemagick matplotlib postgresql gnome ldap ruby ffmpeg animation foreman django audio python:windows-setup python:pyenv git:dulwich sharing:api

CC0 / Public domain dedication To the extent possible under law, d3vid seaward has waived all copyright and related or neighboring rights to "Python in Grasmere notebook, including code snippets" (why? how?)