Begins 0.7.1 released

I released version 0.7 and 0.7.1 of Begins this week. 0.7.1 was a bug fix release for an issue discovered shortly after releasing 0.7. A number of significant features were delivered in 0.7, including:

These new features enable writing a simple Flask web applications like:

import begin
from twoslug import app

@begin.start(auto_convert=True)
def main(host='127.0.0.1', port=8000, debug=False):
    app.run(host=host, port=port, debug=debug)

Begins both ensures that the correct, expected, types are passed to the main function as well as presenting debug as a command line flag rather than an option argument. The help output for the application is:

usage: run.py [--help] [--host HOST] [--port PORT] [--debug]

optional arguments:
  --help                show this help message and exit
  --host HOST, -h HOST  (default: 127.0.0.1)
  --port PORT, -p PORT  (default: 8000)
  --debug, -d           (default: False)

This is the actual development server I have been using while developing TwoSlug.

Begins really should have had a beta release by now. (It's currently still in alpha). The only thing preventing a beta is the lack of proper documentation hosted on Read The Docs. My intention is to focus solely on documentation for the upcoming 0.8 release, which will be the first beta. That's my intention anyway, the strength of my convictions remains to be seen.


My only advice to soon to be fathers

A number of my friends have announced that they will soon become fathers for the first time. I'm extremely excited for them, as are they. Already being a dad I try hard to share my experiences of fatherhood, and not just dispense advice. Each child is unique, each family is different. Advice that would work for me isn't necessarily going to work for someone else. That is, except for one solitary piece of advice I do give to all prospective fathers.

Once you have decided on names, write both names (with correct spelling) on a piece of card and keep it in your wallet.

Leading up to the birth of my first daughter, we alternated between 'belle and 'bella. The day of her birth didn't proceed according to our obstetrician's plan. Standing after at the nurses station, my wife in post-operative care, me in possession of a baby and having no idea what to do now. The nurse asked me if we had chosen a name. I said "yes" and proceeded to do my best goldfish impersonation as I suffered a mental blank.

To this day we're not sure if I used the last name we had actually chosen. It doesn't matter today. Still, for any future fathers out there, save yourself a little extra stress on that big day. And congratulations.


Making a command out of shutil

I love the creating that developers show in making unintended use of a tool to solve a problem. It doesn't matter if that use is a "good idea" or not. Regardless of whether it's a "good idea" or not. The ingenuity and problem solving demonstrated is usually quite fascinating. Like this little hack that my friend mjdorma shared with me that uses Begins' sub-commands.

import shutil
import begin

begin.subcommand(shutil.copy)
begin.subcommand(shutil.copy2)
begin.subcommand(shutil.copyfile)
begin.subcommand(shutil.copymode)
begin.subcommand(shutil.copystat)
begin.subcommand(shutil.copytree)
begin.subcommand(shutil.move)
begin.subcommand(shutil.rmtree)

# Patch in doc before the func is wrapped by begin.start
def patch_doc(doc):
    def decorate(func):
        func.__doc__ = doc
        return func
    return decorate

@begin.start
@patch_doc(shutil.__doc__)
def main():
    pass

This little script gives you access to a number of utility functions from Python's shutil module from the command line. Admittedly there are common Unix utilities that provide most of this functionality. But I still felt it was a nifty and entertaining use of functionality I had just written.

After using Begins for a few weeks this type of application has become a common pattern for Begins. Sub-commands excel at creating small administration programs that are a collection of related commands. Even more exciting is that others groups are successfully orchestrating much larger systems using Begins as a framework. Its terrific to know that Begins is meeting its goal of growing with the developer.

You can download this script from Michael's original GitHub Gist.