I wanted to turn a list like
['*.zip', '*.pyc', '*.log'] into
['--exclude', '*.zip', '--exclude', '*.pyc', '--exclude', '*.log'].
A simple list comprehension doesn’t work as desired:
In [1]: excludes = ['*.zip', '*.pyc', '*.log']
In [2]: [('--exclude', e) for e in excludes]
Out[2]: [('--exclude', '*.zip'), ('--exclude', '*.pyc'), ('--exclude', '*.log')]
The trick is to use a nested comprehension:
In [5]: [arg for pattern in excludes
for arg in ['--exclude', pattern]]
Out[5]: ['--exclude', '*.zip', '--exclude', '*.pyc', '--exclude', '*.log']
Via Hacker News,
"All Springer Textbooks More Than 10 Years Old Available for Free Legal Download".
This includes books from Apress
as well as a ton of those impenetrable gray-and-red
Lecture Notes in Computer Science books.
Update 2015-12-30: No longer available.
Springer aren’t commenting. Presumably a mistake.
[Spoilers]
Young orphaned scavenger living on a desert planet
finds droid with a message,
then hooks up with two rogues in a beat-up ship.
Young hero starts developing a talent for the Force.
Dark-side dork with daddy issues slays daddy in death star duel.
Ace X-wing pilot flies down trench and kills death star.
Where have I seen this movie before?
Episode VII is a distinct improvement over the last set of Star Wars films,
the Anakin prequels.
We care more about Rey and Finn than we ever did about Anakin and Padme.
George Lucas’s characters were wooden and unconvincing;
Lawrence Kasdan (who wrote The Empire Strikes Back and Return of the Jedi),
J.J. Abrams, …continue.
Title: The Magician King
Author: Lev Grossman
Rating: ★ ★ ★ ★ ½
Publisher: Plume
Copyright: 2011
Pages: 400
Keywords: adult fantasy
Reading period: 26–27 December, 2015
[Sequel to The Magicians.]
There are two storylines in The Magician King,
the backstory of Julia’s training as a hedgewitch
and Quentin’s quest for the seven golden keys.
Quentin, along with his high school crush, Julia,
and his fellow Brakebills’ alumni, Eliot and Janet,
have ruled Fillory for a few years.
Bored with being King, he sets off on a quest, taking Julia with him.
Unexpectedly thrust back to Earth,
they desperately strive to return to Fillory, eventually succeeding.
Magic is leaching out of the universe as the old gods awaken,
and …continue.
Title: The Magicians
Author: Lev Grossman
Rating: ★ ★ ★ ★ ½
Publisher: Plume
Copyright: 2009
Pages: 402
Keywords: adult fantasy
Reading period: 20–26 December, 2015
Take a heavy dose of Narnia,
add a hefty dollop of Harry Potter,
stir in some Bret Easton Ellis
and a dash of The Catcher in the Rye,
then cook for adults.
That glib description shortchanges The Magicians,
even though Fillory clearly owes a major debt to Narnia
and the preppy Brakebills College for Magical Pedagogy somewhat resembles Hogwarts.
Quentin Coldwater is an overachieving, solitary math nerd from Brooklyn,
who thinks he’s attending an entrance interview for Princeton
but instead gains admittance to Brakebills.
Magic turns out to be real, but difficult, requiring …continue.
We had a quiet Christmas day.
We’re hosting two couchsurfing young women from Kazakhstan.
They and Raven and Iain were our dinner guests.
We roasted a leg of lamb and an assortment of root vegetables.
For dessert, we had one of my Christmas Puddings.
I shared a house with my friend Muhsin in the mid-90s.
Muhsin is a runner so I started running too,
but I lost the habit not long after I moved in with Emma in ‘98.
A little over a year ago, I went down to the Bay Area for work.
I spent the weekend staying with old friends from Ireland, Paul and Maggie.
Paul had been run down by a car while cycling at twilight at Christmas 2013.
As part of his recovery, he had taken up running,
and a few weeks before my trip, he challenged me to join him in a 5K run for charity.
And so I …continue.
I worked on a Bash script today that sets up various prerequisites for our build.
We need a recent version of Docker
but our Bamboo build agents are running on Ubuntu 14.04,
which has a very old version of Docker.
The script upgrades Docker when it’s first run.
The script may be run more than once during the lifetime of the agent,
so the second and subsequent calls should not upgrade Docker.
Basically, I wanted
if $DOCKER_VERSION < 1.9; then upgrade_docker; fi
Unfortunately, it’s not that easy in Bash.
Here’s what I came up with.
install_latest_docker() {
if docker --version | python -c "min=[1, 9]; import sys; ↩
v=[int(x) for x in …continue.
Last week I made my Christmas Cake,
a week after I made my Christmas Puddings.
Tonight I decorated it with marzipan and royal icing.
[Previously published at the now defunct MetaBrite Dev Blog.]
I spent some time today struggling with setuptools,
trying to make a Python source package
not only include a data file,
but also install that file.
Building the installer
Consider the following source tree layout:
├── MANIFEST.in
├── README.md
├── my_stuff/
│ ├── bar.py
│ ├── foo.py
│ ├── __init__.py
│ └── quux.py
├── models/
│ └── long_ugly_name_20151221.json
└── setup.py*
I wanted to create a Python source distribution, some_package-N.N.N.tar.gz,
which contains the code in the my_stuff directory,
as well as models/long_ugly_name_20151221.json,
using python setup.py sdist.
It’s not that hard to get models/long_ugly_name_20151221.json
included in the tarball.
Add an entry in MANIFEST.in:
include models/*.json
Then be sure to set include_package_data=True
in the call to setup():
from setuptools import setup, find_packages
setup(
…continue.
Previous »
« Next