Why import * is not allowed outside the global scope

So today I was looking at import machinery in Python due to this question about import styles in Persephone, an open source natural language processing library I’ve been contributing to. Looking around at this more I’ve found a couple of things that I didn’t realize before: Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0

How a web page request makes it down to the metal

The other day I was interested in how many steps occur between sending a POST or GET request from a website to the actual processing that happens on the CPU of the server. I figured that I knew bits and pieces of the puzzle but I wanted to see the complete path from the highest

Interfacing Python with C or C++

One of the main downsides of writing applications in Python is that they can run slow. When you run into an insurmountable runtime speed issue the commonly accepted wisdom is to either use a more efficient Python implementation such as PyPy or to write the performance critical code in a more efficient compiled language (usually

Resolving CFFI install issues on Ubuntu

Some of my Python projects rely on a variety of packages, most of which install flawlessly via PIP. Recently I’ve been setting up a new machine running Ubuntu 16.04 and I ran into a few issues installing CFFI via PIP. Essentially CFFI requires some packages that are not installed by default on Ubuntu 16.04, the

Generating python bindings from C++11 with pybind11

Code for this tutorial found here: https://github.com/shuttle1987/pybind11_tutorial_code Recently I was involved in some discussion sparked by this blog post where “rdrewd” was talking about benchmarking a simple program that generated prime numbers in Python. The thing about this that I like is that it’s a very good example of a situation where making pragmatic decisions

Deprecation warnings in python

When you are maintaining a package you want to be able to deprecate functionality and be able to give your users advance warning when you know that something is going away in the future. Because we wish to warn users without breaking the code we want to have the ability to give information without changing

Testing for exceptions with Jasmine

I just made a PR to the KaTeX library to help fix some cryptic error messages. To do this I had a few places raise exceptions early instead of propagating deeply into the code before breaking in strange places with cryptic error messages. The library can only deal with expressions that are strings so I

Markup languages with Git, a document workflow

Currently I’m writing this entry in a text editor that is a WYSIWYG type of editor. This is entirely common, to the point where people are just conditioned to thinking that editing text and WYSIWYG go together. There are however a number of document markup languages that are not WYSIWYG, lightweight ones such as Markdown

Using LaTeX for fast document generation

Many systems have some sort of report generation component. This is often some variation on extracting data from a database (or other sources) then doing some analysis on that data and outputting it in some readable form. Sometimes a requirement is for reports to be available in PDF format. I use a lot of Python

Python comprehension syntax for Java developers

Recently I’ve been working with both Java and Python. One of the jarring differences between Java and Python is the relative brevity of Python code that’s enabled by the various Python language features. In all languages there’s a decision about how much syntactic sugar is used and how succinct the language is, with regards to