August 2nd, 2017

Python Bytes: #37 Rule over the shells with Sultan

Programing, Python, by admin.

<p><strong>Brian #1:</strong> <a href=””><strong>New URL for Python Developer’s Guide</strong></a></p> <ul>
<li>How to contribute to CPython</li>
</ul> <p>Some really useful links that I hadn’t noticed before. Also great ideas to include in a contributing guide for any large open source project:</p> <ul>
<li>Core developers and contributors alike will find the following guides useful:
<li><a href=””>How to Contribute to Open Source</a> (from</li>
<li><a href=””>Building Welcoming Communities</a> (from</li>
<li>Guide for contributing to Python:
<li><a href=””>Getting Started</a></li>
<li><a href=””>Where to Get Help</a></li>
<li><a href=””>Lifecycle of a Pull Request</a></li>
<li><a href=””>Running &amp; Writing Tests</a></li>
<li>Beginner tasks to become familiar with the development process</li>
<li><a href=””>Helping with Documentation</a></li>
<li><a href=””>Increase Test Coverage</a></li>
<li>Advanced tasks for once you are comfortable</li>
<li><a href=””>Silence Warnings From the Test Suite</a></li>
<li>Fixing issues found by the <a href=””>buildbots</a></li>
<li><a href=””>Fixing “easy” Issues (and Beyond)</a></li>
<li><a href=””>Using the Issue Tracker</a> and <a href=””>Helping Triage Issues</a></li>
<li><a href=””>Triaging an Issue</a></li>
<li><a href=””>Experts Index</a></li>
<li><a href=””>Following Python’s Development</a></li>
<li><a href=””>How to Become a Core Developer</a></li>
<li><a href=””>Committing and Pushing Changes</a></li>
<li><a href=””>Development Cycle</a></li>
<li><a href=””>Continuous Integration</a></li>
<li><a href=””>Git Bootcamp and Cheat Sheet</a></li>
</ul> <p><strong>Michael #2:</strong> <a href=””><strong>Sultan: Command and Rule Over Your Shell</strong></a></p> <ul>
<li>Python package for interfacing with command-line utilities, like yum, apt-get, or ls, in a Pythonic manner</li>
</ul> <p>Simple example</p> <pre><code>from sultan.api import Sultan
s = Sultan()
s.sudo(“yum install -y tree”).run()
</code></pre> <p>Better in a context manager:</p> <pre><code>from sultan.api import Sultan with Sultan.load(sudo=True) as s: s.yum(“install -y tree”).run()
</code></pre> <p>Even works remotely:</p> <pre><code>from sultan.api import Sultan with Sultan.load(sudo=True, hostname=””) as sultan: sultan.yum(“install -y tree”).run()
</code></pre> <p><strong>Brian #3:</strong> <a href=””><strong>Flake8Lint</strong></a></p> <ul>
<li>Sublime Text plugin for lint Python files.</li>
<li>Includes these linters and style checkers:
<li><a href=”″><strong>Flake8</strong></a> (used in “Python Flake8 Lint”) is a wrapper around these tools:</li>
<li><a href=”″><strong>pep8</strong></a> is a tool to check your Python code against some of the style conventions in <a href=””>PEP8</a>.</li>
<li><a href=””><strong>PyFlakes</strong></a> checks only for logical errors in programs; it does not perform any check on style.</li>
<li><a href=””><strong>mccabe</strong></a> is a code complexity checker. It is quite useful to detect over-complex code. According to McCabe, anything that goes beyond 10 is too complex. See <a href=””>Cyclomatic_complexity</a>.</li>
<li>There are additional tools used to lint Python files:</li>
<li><a href=””><strong>pydocstyle</strong></a> is a static analysis tool for checking compliance with Python <a href=””>PEP257</a>.</li>
<li><a href=””><strong>pep8-naming</strong></a> is a naming convention checker for Python.</li>
<li><a href=””><strong>flake8-debugger</strong></a> is a flake8 debug statement checker.</li>
<li><a href=””><strong>flake8-import-order</strong></a> is a flake8 plugin that checks import order in the fashion of the Google Python Style Guide (turned off by default).</li>
</ul> <p><strong>Michael #4:</strong> <a href=””><strong>Magic Wormhole</strong></a></p> <ul>
<li>Get things from one computer to another, safely.</li>
<li>A library and a command-line tool named <code>wormhole</code>, which makes it possible to get arbitrary-sized files and directories (or short pieces of text) from one computer to another.</li>
<li>The two endpoints are identified by using identical “wormhole codes”</li>
<li>Video from PyCon 2016: <a href=””></a></li>
<li>The codes are short and human-pronounceable, using a phonetically-distinct wordlist.</li>
<li>As a library too: The wormhole module makes it possible for other applications to use these code-protected channels. </li>
</ul> <p><strong>Brian #5:</strong> <a href=””><strong>Python Virtual Environments Primer</strong></a></p> <ul>
<li>why do we need virtual environments</li>
<li>what are they</li>
<li>how to use them / how do they work</li>
<li>using different versions of python</li>
</ul> <p><strong>Michael #6:</strong> <a href=””><strong>How Rust can replace C, with Python’s help</strong></a></p> <ul>
<li>Why Rust? Rust has
<li>a type system feature that helps eliminate memory leaks,</li>
<li>proper interfaces, called ‘traits’,</li>
<li>better type inference,</li>
<li>better support for concurrency,</li>
<li>(almost) first-class functions that can be passed as arguments.</li>
<li>It isn’t difficult to expose Rust code to Python. A Rust library can expose a C ABI (application binary interface) to Python without too much work. </li>
<li>Some Rust crates (as Rust packages are called) already expose Python bindings to make them useful in Python.</li>
<li>A new spate of projects are making it easier to develop Rust libraries with convenient bindings to Python – and to deploy Python packages that have Rust binaries</li>
<li><a href=””><strong>Rust-CPython</strong></a><strong>:</strong> <ul>
<li><strong>What it is:</strong> A set of bindings in Rust for the CPython runtime. This allows a Rust program to connect to CPython, use its ABI, run Python programs through it, and work with representations of Python objects in Rust itself.</li>
<li><strong>Who it’s for:</strong> Rust programmers who want to hook into CPython and control it from the inside out.</li>
<li><a href=”″><strong>PyO3</strong></a>
<li><strong>What it is:</strong> For Rust developers, the PyO3 project provides a basic way to write Rust software with bindings to Python in both directions. A Rust program can interface with Python objects and the Python interpreter, and can expose Rust methods to a Python program in the same way a C module does.</li>
<li><strong>Who it’s for:</strong> Those writing modules that work closely with the Python runtime, and need to interact directly with it.</li>
<li><a href=””><strong>Snaek</strong></a>
<li><strong>What it is:</strong> Another project in the early stages, Snaek lets developers create Rust libraries that are loaded dynamically into Python as needed, but don’t rely on being linked statically against Python’s runtime.</li>
<li>Doesn’t use CTypes but CFFI</li>
<li><strong>Who it’s for:</strong> Those who want to expose methods written in Rust to a Python script, or for Rust developers who don’t want or need to become familiar with Python.</li>
<li>And there is a cookiecutter project / template too
<li><a href=””></a></li>
<li>“A very important goal of the project,” writes its maintainers, “is that it be able to produce a binary distribution (Wheel) which will not require the end user to actually compile the Rust code themselves.”</li>

Back Top

Leave a Reply