background preloader

Python 3

Facebook Twitter

An idiot’s guide to Python documentation with Sphinx and ReadTheDocs – Samposium. This is the third occasion that I’ve come to set up a Python package with all the trimmings, including nice looking Sphinx-backed documentation hosted on ReadTheDocs.

An idiot’s guide to Python documentation with Sphinx and ReadTheDocs – Samposium

It is also the third occasion where I’ve spent a few hours and a dozen commits trying to work out how I made everything work last time. So for my future sanity and possibly yours, here’s a quick guide1 (and some links to resources) on how to do the things that I don’t do often enough to remember first hand. To begin… Notes on Using Sphinx — sphinx-tutorial 2013.0 documentation.

Here are some quick notes on running Sphinx successfully.

Notes on Using Sphinx — sphinx-tutorial 2013.0 documentation

Each topic will be elaborated upon at the right point during our class. Starting a Sphinx project¶ The wonder of a properly designed framework is that it begins by positioning you at a working starting point instead of leaving you to wander endlessly through a README that, after dozens of steps, leaves you guessing which step you did improperly to have wound up with a broken install. Sphinx gets you started with sphinx-quickstart.

Here is how a quick-start session will look, paying attention only to its prompts and how you should respond (which is mostly by pressing Return over and over), when you use it to create a new project: Numpy and Scipy Documentation — Numpy and Scipy documentation. Colored 1.3.4. Simple library for color and formatting to terminal Very simple Python library for color and formatting in terminal.

colored 1.3.4

Collection of color codes and names for 256 color terminal setups. The following is a list of 256 colors for Xterm, containing an example of the displayed color, Xterm Name, Xterm Number and HEX. Video Demo The following colors works with most terminals and terminals emulators. Jq. Command Line Interface — Pygments. You can use Pygments from the shell, provided you installed the pygmentize script: $ pygmentize print "Hello World" will print the file to standard output, using the Python lexer (inferred from the file name extension) and the terminal formatter (because you didn’t give an explicit formatter name).

Command Line Interface — Pygments

If you want HTML output: $ pygmentize -f html -l python -o test.html As you can see, the -l option explicitly selects a lexer. Glade - A User Interface Designer. Pygubu Package Index > pygubu > Not Logged In Status Nothing to report pygubu


Python on the Web: The Amazing Things You Can Build. In many ways, we’re living in the golden age of web development.

Python on the Web: The Amazing Things You Can Build

Web technologies have never been as refined and flexible as they are today, and if you want to build a high-quality website or web app, you have so many viable ways to get there — including the use of Python. 5 Reasons Why Python Programming Is Not Useless 5 Reasons Why Python Programming Is Not Useless Python -- You either love it or you hate it. You might even swing from one end to the other like a pendulum.

Regardless, Python is a language that's hard to be ambivalent about. Read More Contrary to popular belief, Python isn’t only useful for data processing and utility scripts. 6.8. rlcompleter — Completion function for GNU readline — Python 3.5.3 documentation. Source code: Lib/ The rlcompleter module defines a completion function suitable for the readline module by completing valid Python identifiers and keywords.

6.8. rlcompleter — Completion function for GNU readline — Python 3.5.3 documentation

When this module is imported on a Unix platform with the readline module available, an instance of the Completer class is automatically created and its complete() method is set as the readline completer. Example: Overview — Sphinx 1.4.9 documentation. Getting Started with Django Channels. Documenting your API - Django REST framework. A REST API should spend almost all of its descriptive effort in defining the media type(s) used for representing resources and driving application state.— Roy Fielding, REST APIs must be hypertext driven There are a variety of approaches to API documentation.

Documenting your API - Django REST framework

This document introduces a few of the various tools and options you might choose from. The approaches should not be considered exclusive - you may want to provide more than one documentation style for you API, such as a self describing API that also includes static documentation of the various API endpoints. Endpoint documentation The most common way to document Web APIs today is to produce documentation that lists the API endpoints verbatim, and describes the allowable operations on each. DRF Docs DRF Docs allows you to document Web APIs made with Django REST Framework and it is authored by Emmanouil Konstantinidis.

Both this package and Django REST Swagger are fully documented, well supported, and come highly recommended. Supports: Integrate OAuth 2 Into Your Django/DRF Back-end. We’ve all been there.

Integrate OAuth 2 Into Your Django/DRF Back-end

You’re working on the API back-end, and you’re happy with how it’s going. You’ve recently completed the minimal viable product (MVP), the tests are all passing, and you’re looking forward to implementing some new features. Then the boss sends you an email: “By the way, we need to let people log in via Facebook and Google; they shouldn’t have to create an account just for a little site like ours.” Great. Scope creep strikes again. The good news is that OAuth 2 has emerged as the industry standard for social and third-party authentication (used by services such as Facebook, Google, etc.) so you can focus on understanding and implementing that standard to support a wide range of social authentication providers.

It’s likely you’re not familiar with OAuth 2; I wasn’t, when this happened to me. Full Stack Python. Python binding. The README file of the source code has a quick summary of information.

Python binding

We also have generated documentation here. The Sphinx docs contain autogenerated coverage of the API as presented in Python, as well as descriptions of where PyZMQ may differ from other ØMQ bindings. The definitive guide on how to use static, class or abstract methods in Python. Doing code reviews is a great way to discover things that people might struggle to comprehend. While proof-reading OpenStack patches recently, I spotted that people were not using correctly the various decorators Python provides for methods. So here's my attempt at providing me a link to send them to in my next code reviews. :-) This article has been kindly converted and recorded as a video by Webucator, provider of Python training.

(A Semi-Official) Python FAQ Zone. This effbot zone, a sister site to the Python Tutorial Wiki, contains a copy of the standard Python FAQ. This site replaces the version hosted at infogami. This site is being used as an editing and staging area; “stable” versions will be published over at at regular intervals, once all the tools are in place. Modifying the __add__ method of a Python Class. Learn how you should modify the __add__ method of a Python class to be able to add two instances of a custom object. We also talk about the __radd__ method, necessary to sum a list of instances. When we sum two objects in Python, like. Advanced Objects: Special Methods. At first glance, The __new__() method seems similar to the __init__() method, but it is actually quite different.

You will remember that you instantiate a class (that is, create a new instance of that class) by calling the class. The __init__() method returns nothing—it merely initializes what __new__() has created. The __new__() method, on the other hand, returns the object that will become the return value of the instantiation call. Like __init__(), __new__() receives the arguments that the caller passes when calling the class. Python3 Tutorial: Magic Methods. Introduction The so-called magic methods have nothing to do with wizardry. You have already seen them in previous chapters of our tutorial. IdleX - IDLE Extensions for Python. Redis Quick Start – Redis. This is a quick start document that targets people without prior experience with Redis.

Reading this document will help you: Download and compile Redis to start hacking. Use redis-cli to access the server. Use Redis from your application. Understand how Redis persistence works. The suggested way of installing Redis is compiling it from sources as Redis has no dependencies other than a working GCC compiler and libc. You can either download the latest Redis tar ball from the web site, or you can alternatively use this special URL that always points to the latest stable Redis version, that is, In order to compile Redis follow this simple steps:

Virtualenv with Eclipse with PyDev on Windows 10 – London App Developer. Python Virtual Environments - a primer. In this article, we’ll show how to use virtual environments to create and manage separate environments for your Python projects, each using different versions of Python for execution, as well as how Python dependencies are stored and resolved. Updated 11/06/2016: Added section on changing Python versions with virtualenv. Why the need for virtual environments? Python, like most other modern programming languages, has its own unique way of downloading, storing, and resolving packages (or modules). While this has its advantages, there were some interesting decisions made about package storage and resolution, which has lead to some problems – namely how and where packages are stored. There are a few different locations where these packages can be installed on your system. On Mac OS X, you can easily find where sys.prefix points to using the Python shell: So, why do all of these little details matter?

What is a virtual environment? Using virtual environments What does each folder contain? Homebrew. Multiprocessing — Manage Processes Like Threads — PyMOTW 3. What’s New In Python 3.6 — Python 3.6.0 documentation. Communication Between Processes - Python Module of the Week. Welcome to the wxPython Phoenix Project — wxPython Phoenix 3.0.3 documentation. Index of /Phoenix/snapshot-builds. How to install Django on Windows. Installation — Wand 0.4.5. Requests: HTTP for Humans — Requests 2.10.0 documentation.

Jupyter and the future of IPython — IPython. Try Jupyter! Python Properties. Inner functions - what are they good for? by python-xy.